summaryrefslogtreecommitdiff
path: root/libraries/base/Data/List.hs
diff options
context:
space:
mode:
authorHerbert Valerio Riedel <hvr@gnu.org>2013-09-15 23:05:05 +0200
committerHerbert Valerio Riedel <hvr@gnu.org>2013-09-17 09:54:07 +0200
commit0f5eae0232a86ec57d841a83e6929361e2751270 (patch)
tree7cc7b87fce8238cd9ff6b65fb0c37f515191aa6e /libraries/base/Data/List.hs
parent43ece172e7045d5ba633be6193f3e908eaa81f00 (diff)
downloadhaskell-0f5eae0232a86ec57d841a83e6929361e2751270.tar.gz
Constant-fold `__GLASGOW_HASKELL__` CPP conditionals
Now that HUGS and NHC specific code has been removed, this commit "folds" the now redundant `#if((n)def)`s containing `__GLASGOW_HASKELL__`. This renders `base` officially GHC only. This commit also removes redundant `{-# LANGUAGE CPP #-}`. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
Diffstat (limited to 'libraries/base/Data/List.hs')
-rw-r--r--libraries/base/Data/List.hs33
1 files changed, 1 insertions, 32 deletions
diff --git a/libraries/base/Data/List.hs b/libraries/base/Data/List.hs
index e7e8602cba..7998976baa 100644
--- a/libraries/base/Data/List.hs
+++ b/libraries/base/Data/List.hs
@@ -208,12 +208,10 @@ module Data.List
import Data.Maybe
import Data.Char ( isSpace )
-#ifdef __GLASGOW_HASKELL__
import GHC.Num
import GHC.Real
import GHC.List
import GHC.Base
-#endif
infix 5 \\ -- comment to fool cpp
@@ -270,8 +268,7 @@ findIndex p = listToMaybe . findIndices p
-- | The 'findIndices' function extends 'findIndex', by returning the
-- indices of all elements satisfying the predicate, in ascending order.
findIndices :: (a -> Bool) -> [a] -> [Int]
-
-#if defined(USE_REPORT_PRELUDE) || !defined(__GLASGOW_HASKELL__)
+#ifdef USE_REPORT_PRELUDE
findIndices p xs = [ i | (x,i) <- zip xs [0..], p x]
#else
-- Efficient definition
@@ -516,8 +513,6 @@ insertBy cmp x ys@(y:ys')
GT -> y : insertBy cmp x ys'
_ -> x : ys
-#ifdef __GLASGOW_HASKELL__
-
-- | 'maximum' returns the maximum value from a list,
-- which must be non-empty, finite, and of an ordered type.
-- It is a special case of 'Data.List.maximumBy', which allows the
@@ -557,8 +552,6 @@ strictMinimum :: (Ord a) => [a] -> a
strictMinimum [] = errorEmptyList "minimum"
strictMinimum xs = foldl1' min xs
-#endif /* __GLASGOW_HASKELL__ */
-
-- | The 'maximumBy' function takes a comparison function and a list
-- and returns the greatest element of the list by the comparison function.
-- The list must be finite and non-empty.
@@ -996,29 +989,21 @@ unfoldr f b =
-- | A strict version of 'foldl'.
foldl' :: (b -> a -> b) -> b -> [a] -> b
-#ifdef __GLASGOW_HASKELL__
foldl' f z0 xs0 = lgo z0 xs0
where lgo z [] = z
lgo z (x:xs) = let z' = f z x in z' `seq` lgo z' xs
-#else
-foldl' f a [] = a
-foldl' f a (x:xs) = let a' = f a x in a' `seq` foldl' f a' xs
-#endif
-#ifdef __GLASGOW_HASKELL__
-- | 'foldl1' is a variant of 'foldl' that has no starting value argument,
-- and thus must be applied to non-empty lists.
foldl1 :: (a -> a -> a) -> [a] -> a
foldl1 f (x:xs) = foldl f x xs
foldl1 _ [] = errorEmptyList "foldl1"
-#endif /* __GLASGOW_HASKELL__ */
-- | A strict version of 'foldl1'
foldl1' :: (a -> a -> a) -> [a] -> a
foldl1' f (x:xs) = foldl' f x xs
foldl1' _ [] = errorEmptyList "foldl1'"
-#ifdef __GLASGOW_HASKELL__
-- -----------------------------------------------------------------------------
-- List sum and product
@@ -1056,7 +1041,6 @@ product l = prod l 1
-- characters. The resulting strings do not contain newlines.
lines :: String -> [String]
lines "" = []
-#ifdef __GLASGOW_HASKELL__
-- Somehow GHC doesn't detect the selector thunks in the below code,
-- so s' keeps a reference to the first line via the pair and we have
-- a space leak (cf. #4334).
@@ -1067,12 +1051,6 @@ lines s = cons (case break (== '\n') s of
_:s'' -> lines s''))
where
cons ~(h, t) = h : t
-#else
-lines s = let (l, s') = break (== '\n') s
- in l : case s' of
- [] -> []
- (_:s'') -> lines s''
-#endif
-- | 'unlines' is an inverse operation to 'lines'.
-- It joins lines, after appending a terminating newline to each.
@@ -1108,12 +1086,3 @@ unwords [] = ""
unwords [w] = w
unwords (w:ws) = w ++ ' ' : unwords ws
#endif
-
-#else /* !__GLASGOW_HASKELL__ */
-
-errorEmptyList :: String -> a
-errorEmptyList fun =
- error ("Prelude." ++ fun ++ ": empty list")
-
-#endif /* !__GLASGOW_HASKELL__ */
-