%
-% (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
+% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
\section[Maybes]{The `Maybe' types and associated utility functions}
\begin{code}
-#include "HsVersions.h"
-
module Maybes (
-- Maybe(..), -- no, it's in 1.3
MaybeErr(..),
catMaybes
) where
-#if __GLASGOW_HASKELL__ >= 204
-import Maybe( catMaybes, mapMaybe )
-#endif
+#include "HsVersions.h"
+import Maybe( catMaybes, mapMaybe )
\end{code}
Nothing -> Nothing
Just xs -> Just (x:xs)
-#if __GLASGOW_HASKELL__ < 204
- -- After 2.04 we get these from the library Maybe
-catMaybes :: [Maybe a] -> [a]
-catMaybes [] = []
-catMaybes (Nothing : xs) = catMaybes xs
-catMaybes (Just x : xs) = (x : catMaybes xs)
-
-mapMaybe :: (a -> Maybe b) -> [a] -> [b]
-mapMaybe f [] = []
-mapMaybe f (x:xs) = case f x of
- Just y -> y : mapMaybe f xs
- Nothing -> mapMaybe f xs
-#endif
\end{code}
@firstJust@ takes a list of @Maybes@ and returns the