summaryrefslogtreecommitdiff
path: root/libraries/base/Data
diff options
context:
space:
mode:
authorross <unknown>2004-09-28 23:34:26 +0000
committerross <unknown>2004-09-28 23:34:26 +0000
commit7b1167324542c0fec8776325845c6e039e02efa1 (patch)
tree7509b47ef65af3ab6e2b78c3e38d24671569ba1f /libraries/base/Data
parent7ba52e718c2e73975326434d4a38d846c958e104 (diff)
downloadhaskell-7b1167324542c0fec8776325845c6e039e02efa1.tar.gz
[project @ 2004-09-28 23:34:26 by ross]
unbreak for non-GHC implementations
Diffstat (limited to 'libraries/base/Data')
-rw-r--r--libraries/base/Data/List.hs15
1 files changed, 14 insertions, 1 deletions
diff --git a/libraries/base/Data/List.hs b/libraries/base/Data/List.hs
index 15088e9000..7250333f38 100644
--- a/libraries/base/Data/List.hs
+++ b/libraries/base/Data/List.hs
@@ -455,6 +455,8 @@ 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
@@ -492,6 +494,8 @@ 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.
@@ -842,11 +846,13 @@ 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
+#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
@@ -925,4 +931,11 @@ unwords [] = ""
unwords [w] = w
unwords (w:ws) = w ++ ' ' : unwords ws
#endif
-#endif /* __GLASGOW_HASKELL__ */
+
+#else /* !__GLASGOW_HASKELL__ */
+
+errorEmptyList :: String -> a
+errorEmptyList fun =
+ error ("Prelude." ++ fun ++ ": empty list")
+
+#endif /* !__GLASGOW_HASKELL__ */