| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
GHC.Data.Maybe
Contents
Synopsis
- module Data.Maybe
- data MaybeErr err val
- failME :: err -> MaybeErr err val
- isSuccess :: MaybeErr err val -> Bool
- orElse :: Maybe a -> a -> a
- firstJust :: Maybe a -> Maybe a -> Maybe a
- firstJusts :: Foldable f => f (Maybe a) -> Maybe a
- firstJustsM :: (Monad m, Foldable f) => f (m (Maybe a)) -> m (Maybe a)
- whenIsJust :: Monad m => Maybe a -> (a -> m ()) -> m ()
- expectJust :: HasCallStack => String -> Maybe a -> a
- rightToMaybe :: Either a b -> Maybe b
- newtype MaybeT (m :: Type -> Type) a = MaybeT {}
- liftMaybeT :: Monad m => m a -> MaybeT m a
- tryMaybeT :: IO a -> MaybeT IO a
Documentation
module Data.Maybe
data MaybeErr err val Source #
Instances
| Applicative (MaybeErr err) Source # | |
Defined in GHC.Data.Maybe Methods pure :: a -> MaybeErr err a Source # (<*>) :: MaybeErr err (a -> b) -> MaybeErr err a -> MaybeErr err b Source # liftA2 :: (a -> b -> c) -> MaybeErr err a -> MaybeErr err b -> MaybeErr err c Source # (*>) :: MaybeErr err a -> MaybeErr err b -> MaybeErr err b Source # (<*) :: MaybeErr err a -> MaybeErr err b -> MaybeErr err a Source # | |
| Functor (MaybeErr err) Source # | |
| Monad (MaybeErr err) Source # | |
firstJusts :: Foldable f => f (Maybe a) -> Maybe a Source #
Takes a list of Maybes and returns the first Just if there is one, or
Nothing otherwise.
firstJustsM :: (Monad m, Foldable f) => f (m (Maybe a)) -> m (Maybe a) Source #
Takes computations returnings Maybes; tries each one in order.
The first one to return a Just wins. Returns Nothing if all computations
return Nothing.
whenIsJust :: Monad m => Maybe a -> (a -> m ()) -> m () Source #
expectJust :: HasCallStack => String -> Maybe a -> a Source #
rightToMaybe :: Either a b -> Maybe b Source #
MaybeT
newtype MaybeT (m :: Type -> Type) a Source #
The parameterizable maybe monad, obtained by composing an arbitrary
monad with the Maybe monad.
Computations are actions that may produce a value or exit.
The return function yields a computation that produces that
value, while >>= sequences two subcomputations, exiting if either
computation does.
Instances
liftMaybeT :: Monad m => m a -> MaybeT m a Source #