-- | This file differs from the Einar original (itself automatically
-- produced by decommenting an obsolete GHC source file, apparently) with
-- nearly all the functions removed.
module Util.Maybes (
   fromMaybes, -- :: [Maybe a] -> Maybe [a]
      -- check that all the Maybes are really Just's.
   ) where

fromMaybes :: [Maybe a] -> Maybe [a]
fromMaybes :: [Maybe a] -> Maybe [a]
fromMaybes [] = [a] -> Maybe [a]
forall a. a -> Maybe a
Just []
fromMaybes (Maybe a
Nothing : [Maybe a]
_) = Maybe [a]
forall a. Maybe a
Nothing
fromMaybes (Just a
a : [Maybe a]
rest) = ([a] -> [a]) -> Maybe [a] -> Maybe [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a
a a -> [a] -> [a]
forall a. a -> [a] -> [a]
:) ([Maybe a] -> Maybe [a]
forall a. [Maybe a] -> Maybe [a]
fromMaybes [Maybe a]
rest)