Module

Control.Monad.Maybe.Trans

Package
purescript-transformers
Repository
purescript/purescript-transformers

This module defines the MaybeT monad transformer.

#MaybeT Source

newtype MaybeT :: (Type -> Type) -> Type -> Typenewtype MaybeT m a

The MaybeT monad transformer.

This monad transformer extends the base monad, supporting failure and alternation via the MonadPlus type class.

Constructors

Instances

#runMaybeT Source

runMaybeT :: forall m a. MaybeT m a -> m (Maybe a)

Run a computation in the MaybeT monad.

#mapMaybeT Source

mapMaybeT :: forall m1 m2 a b. (m1 (Maybe a) -> m2 (Maybe b)) -> MaybeT m1 a -> MaybeT m2 b

Change the result type of a MaybeT monad action.

Re-exports from Control.Monad.Trans.Class

#MonadTrans Source

class MonadTrans :: ((Type -> Type) -> Type -> Type) -> Constraintclass MonadTrans t  where

The MonadTrans type class represents monad transformers.

A monad transformer is a type constructor of kind (* -> *) -> * -> *, which takes a Monad as its first argument, and returns another Monad.

This allows us to add additional effects to an existing monad. By iterating this process, we create monad transformer stacks, which contain all of the effects required for a particular computation.

The laws state that lift is a Monad morphism.

Laws:

  • lift (pure a) = pure a
  • lift (do { x <- m ; y }) = do { x <- lift m ; lift y }

Members