X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Futils%2FMaybes.lhs;fp=compiler%2Futils%2FMaybes.lhs;h=8a6a5f441e2db9fc62b4345047c70d605984c803;hp=d4f8346f1495cb003b6b89cc49abbe715e96c13c;hb=3659ebdaca5124c4efb9dd9e8894054d34187deb;hpb=63179a7b10069d8f69f5bceef27008c9c7fb0aa8 diff --git a/compiler/utils/Maybes.lhs b/compiler/utils/Maybes.lhs index d4f8346..8a6a5f4 100644 --- a/compiler/utils/Maybes.lhs +++ b/compiler/utils/Maybes.lhs @@ -35,14 +35,9 @@ infixr 4 `orElse` maybeToBool :: Maybe a -> Bool maybeToBool Nothing = False maybeToBool (Just _) = True -\end{code} - -@catMaybes@ takes a list of @Maybe@s and returns a list of -the contents of all the @Just@s in it. @allMaybes@ collects -a list of @Justs@ into a single @Just@, returning @Nothing@ if there -are any @Nothings@. -\begin{code} +-- | Collects a list of @Justs@ into a single @Just@, returning @Nothing@ if +-- there are any @Nothings@. allMaybes :: [Maybe a] -> Maybe [a] allMaybes [] = Just [] allMaybes (Nothing : _) = Nothing @@ -50,12 +45,8 @@ allMaybes (Just x : ms) = case allMaybes ms of Nothing -> Nothing Just xs -> Just (x:xs) -\end{code} - -@firstJust@ takes a list of @Maybes@ and returns the -first @Just@ if there is one, or @Nothing@ otherwise. - -\begin{code} +-- | Takes a list of @Maybes@ and returns the first @Just@ if there is one, or +-- @Nothing@ otherwise. firstJust :: [Maybe a] -> Maybe a firstJust [] = Nothing firstJust (Just x : _) = Just x