-- Maybe(..), -- no, it's in 1.3
MaybeErr(..),
+ mapMaybe,
allMaybes,
firstJust,
expectJust,
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