Community
Modules 24

Control.Monad.Trans.Maybe

experimental

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.

The MaybeT monad transformer

newtype MaybeT m a

The parameterizable maybe monad, a strict 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.

MaybeT :: m (Maybe a) -> MaybeT m a

mapMaybeT :: (m (Maybe a) -> n (Maybe b)) -> MaybeT m a -> MaybeT n b

Transform the computation inside a MaybeT.

  • runMaybeT (mapMaybeT f m) = f (runMaybeT m)

Monad transformations

hoistMaybe :: (Applicative m) => Maybe b -> MaybeT m b

Convert a Maybe computation to MaybeT.

maybeToExceptT :: (Functor m) => e -> MaybeT m a -> ExceptT e m a

Convert a MaybeT computation to ExceptT, with a default exception value.

exceptToMaybeT :: (Functor m) => ExceptT e m a -> MaybeT m a

Convert a ExceptT computation to MaybeT, discarding the value of any exception.

Lifting other operations

liftCallCC :: CallCC m (Maybe a) (Maybe b) -> CallCC (MaybeT m) a b

Lift a callCC operation to the new monad.

liftCatch :: Catch e m (Maybe a) -> Catch e (MaybeT m) a

Lift a catchE operation to the new monad.

liftListen :: (Monad m) => Listen w m (Maybe a) -> Listen w (MaybeT m) a

Lift a listen operation to the new monad.

liftPass :: (Monad m) => Pass w m (Maybe a) -> Pass w (MaybeT m) a

Lift a pass operation to the new monad.

Instances

23
  • instance (Generic m, Generic a) => Generic (MaybeT m a)
  • instance (Generic1 m, Generic1 a) => Generic1 (MaybeT m a)
  • instance (Eq1 m) => Eq1 (MaybeT m)
  • instance (Ord1 m) => Ord1 (MaybeT m)
  • instance (Read1 m) => Read1 (MaybeT m)
  • instance (Show1 m) => Show1 (MaybeT m)
  • instance (Eq1 m, Eq a) => Eq (MaybeT m a)
  • instance (Ord1 m, Ord a) => Ord (MaybeT m a)
  • instance (Read1 m, Read a) => Read (MaybeT m a)
  • instance (Show1 m, Show a) => Show (MaybeT m a)
  • instance (Functor m) => Functor (MaybeT m)
  • instance (Foldable f) => Foldable (MaybeT f)
  • instance (Traversable f) => Traversable (MaybeT f)
  • instance (Functor m, Monad m) => Applicative (MaybeT m)
  • instance (Functor m, Monad m) => Alternative (MaybeT m)
  • instance (Monad m) => Monad (MaybeT m)
  • instance (Monad m) => Fail.MonadFail (MaybeT m)
  • instance (Monad m) => MonadPlus (MaybeT m)
  • instance (MonadFix m) => MonadFix (MaybeT m)
  • instance MonadTrans MaybeT
  • instance (MonadIO m) => MonadIO (MaybeT m)
  • instance (MonadZip m) => MonadZip (MaybeT m)
  • instance Contravariant m => Contravariant (MaybeT m)
Maintainer
R.Paterson@city.ac.uk
Portability
portable
Copyright
(c) 2007 Yitzak Gale, Eric Kidd
License
BSD-style (see the file LICENSE)
Build record and source files

Community contribution. The service has not verified this documentation.

Target: Linux on x86-64. Some inferred types and resolved links are not available.

Generator: aihc-haddock-858b1951-web-1

Metadata snapshot: ac77ab7d2b1e88487eeab41661abedb7bfb8bc846deb92e7874c08d166bff65d

Open the dependency plan · Download the documentation model

Import a package

Enter a package name and an exact version from Hackage. The site contains imported versions only.