Copyright | (c) 2007 Yitzak Gale Eric Kidd |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | R.Paterson@city.ac.uk |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
The MaybeT
monad transformer extends a monad with the ability to exit
the computation without returning a value.
A sequence of actions produces a value only if all the actions in the sequence do. If one exits, the rest of the sequence is skipped and the composite action exits.
For a variant allowing a range of exception values, see Control.Monad.Trans.Except.
Synopsis
- newtype MaybeT (m :: Type -> Type) a = MaybeT {}
- mapMaybeT :: (m (Maybe a) -> n (Maybe b)) -> MaybeT m a -> MaybeT n b
- hoistMaybe :: forall (m :: Type -> Type) b. Applicative m => Maybe b -> MaybeT m b
- maybeToExceptT :: forall (m :: Type -> Type) e a. Functor m => e -> MaybeT m a -> ExceptT e m a
- exceptToMaybeT :: forall (m :: Type -> Type) e a. Functor m => ExceptT e m a -> MaybeT m a
- liftCallCC :: CallCC m (Maybe a) (Maybe b) -> CallCC (MaybeT m) a b
- liftCatch :: Catch e m (Maybe a) -> Catch e (MaybeT m) a
- liftListen :: Monad m => Listen w m (Maybe a) -> Listen w (MaybeT m) a
- liftPass :: Monad m => Pass w m (Maybe a) -> Pass w (MaybeT m) a
The MaybeT monad transformer
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
Monad transformations
hoistMaybe :: forall (m :: Type -> Type) b. Applicative m => Maybe b -> MaybeT m b Source #
maybeToExceptT :: forall (m :: Type -> Type) e a. Functor m => e -> MaybeT m a -> ExceptT e m a Source #
Lifting other operations
liftCallCC :: CallCC m (Maybe a) (Maybe b) -> CallCC (MaybeT m) a b Source #
Lift a callCC
operation to the new monad.
liftCatch :: Catch e m (Maybe a) -> Catch e (MaybeT m) a Source #
Lift a catchE
operation to the new monad.