-- Maybe(..), -- no, it's in 1.3
MaybeErr(..),
+ mapMaybe,
allMaybes,
firstJust,
expectJust,
#if defined(COMPILING_GHC)
-CHK_Ubiq() -- debugging consistency check
+CHK_Ubiq() -- debugging consistency check
-import Unique (Unique) -- only for specialising
+IMPORT_DELOOPER( SpecLoop ) -- Specialisation
+import Unique (Unique) -- only for specialising
#else
import Maybe -- renamer will tell us if there are any conflicts
allMaybes (Just x : ms) = case (allMaybes ms) of
Nothing -> Nothing
Just xs -> Just (x: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
\end{code}
@firstJust@ takes a list of @Maybes@ and returns the
:: [(FAST_STRING, b)] -> FAST_STRING -> Maybe b
, [(Int, b)] -> Int -> Maybe b
, [(Unique, b)] -> Unique -> Maybe b
- , [(RdrName, b)] -> RdrName -> Maybe b
#-}
#endif
\end{code}