[project @ 2003-05-27 08:46:38 by malcolm]
[ghc-base.git] / Data / List.hs
index 1531a3e..856e0e9 100644 (file)
 
 module Data.List
    ( 
+#ifdef __NHC__
+     [] (..)
+   ,
+#endif
      elemIndex        -- :: (Eq a) => a -> [a] -> Maybe Int
    , elemIndices       -- :: (Eq a) => a -> [a] -> [Int]
 
@@ -132,6 +136,10 @@ module Data.List
 
    ) where
 
+#ifdef __NHC__
+import Prelude hiding (Maybe(..))
+#endif
+
 import Data.Maybe
 
 #ifdef __GLASGOW_HASKELL__
@@ -161,19 +169,15 @@ findIndex p     = listToMaybe . findIndices p
 
 findIndices      :: (a -> Bool) -> [a] -> [Int]
 
-#ifdef USE_REPORT_PRELUDE
+#if defined(USE_REPORT_PRELUDE) || !defined(__GLASGOW_HASKELL__)
 findIndices p xs = [ i | (x,i) <- zip xs [0..], p x]
 #else
-#ifdef __HUGS__
-findIndices p xs = [ i | (x,i) <- zip xs [0..], p x]
-#else 
 -- Efficient definition
 findIndices p ls = loop 0# ls
                 where
                   loop _ [] = []
                   loop n (x:xs) | p x       = I# n : loop (n +# 1#) xs
                                 | otherwise = loop (n +# 1#) xs
-#endif  /* __HUGS__ */
 #endif  /* USE_REPORT_PRELUDE */
 
 isPrefixOf              :: (Eq a) => [a] -> [a] -> Bool
@@ -527,8 +531,8 @@ merge cmp xs [] = xs
 merge cmp [] ys = ys
 merge cmp (x:xs) (y:ys)
  = case x `cmp` y of
-       LT -> x : merge cmp    xs (y:ys)
-       _  -> y : merge cmp (x:xs)   ys
+        GT -> y : merge cmp (x:xs)   ys
+        _  -> x : merge cmp    xs (y:ys)
 
 wrap :: a -> [a]
 wrap x = [x]
@@ -595,7 +599,7 @@ foldl'           :: (a -> b -> a) -> a -> [b] -> a
 foldl' f a []     = a
 foldl' f a (x:xs) = let a' = f a x in a' `seq` foldl' f a' xs
 
-#ifndef __HUGS__
+#ifdef __GLASGOW_HASKELL__
 -- -----------------------------------------------------------------------------
 -- List sum and product
 
@@ -618,4 +622,4 @@ product     l       = prod l 1
     prod []     a = a
     prod (x:xs) a = prod xs (a*x)
 #endif
-#endif  /* __HUGS__ */
+#endif  /* __GLASGOW_HASKELL__ */