Control.Monad.Except.Trans
- Package
- purescript-transformers
- Repository
- purescript/purescript-transformers
This module defines the exception monad transformer ExceptT
.
#ExceptT Source
newtype ExceptT e m a
A monad transformer which adds exceptions to other monads, in the same way
as Except
. As before, e
is the type of exceptions, and a
is the type
of successful results. The new type parameter m
is the inner monad that
computations run in.
Constructors
Instances
Newtype (ExceptT e m a) _
(Functor m) => Functor (ExceptT e m)
(Monad m) => Apply (ExceptT e m)
(Monad m) => Applicative (ExceptT e m)
(Monad m) => Bind (ExceptT e m)
(Monad m) => Monad (ExceptT e m)
(MonadRec m) => MonadRec (ExceptT e m)
(Semigroup e, Monad m) => Alt (ExceptT e m)
(Monoid e, Monad m) => Plus (ExceptT e m)
(Monoid e, Monad m) => Alternative (ExceptT e m)
(Monoid e, Monad m) => MonadPlus (ExceptT e m)
(Monoid e, Monad m) => MonadZero (ExceptT e m)
MonadTrans (ExceptT e)
(MonadEffect m) => MonadEffect (ExceptT e m)
(MonadCont m) => MonadCont (ExceptT e m)
(Monad m) => MonadThrow e (ExceptT e m)
(Monad m) => MonadError e (ExceptT e m)
(MonadAsk r m) => MonadAsk r (ExceptT e m)
(MonadReader r m) => MonadReader r (ExceptT e m)
(MonadState s m) => MonadState s (ExceptT e m)
(MonadTell w m) => MonadTell w (ExceptT e m)
(MonadWriter w m) => MonadWriter w (ExceptT e m)
#runExceptT Source
runExceptT :: forall a m e. ExceptT e m a -> m (Either e a)
The inverse of ExceptT
. Run a computation in the ExceptT
monad.
#withExceptT Source
withExceptT :: forall a m e' e. Functor m => (e -> e') -> ExceptT e m a -> ExceptT e' m a
Transform any exceptions thrown by an ExceptT
computation using the given function.
#mapExceptT Source
mapExceptT :: forall b a n m e' e. (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b
Transform the unwrapped computation using the given function.
#except Source
except :: forall a m e. Applicative m => Either e a -> ExceptT e m a
Construct a computation in the ExceptT
transformer from an Either
value.
Re-exports from Control.Monad.Error.Class
#MonadError Source
class (MonadThrow e m) <= MonadError e m | m -> e where
The MonadError
type class represents those monads which support catching
errors.
catchError x f
calls the error handlerf
if an error is thrown during the evaluation ofx
.
An implementation is provided for ExceptT
, and for other monad transformers
defined in this library.
Laws:
- Catch:
catchError (throwError e) f = f e
- Pure:
catchError (pure a) f = pure a
Members
catchError :: forall a. m a -> (e -> m a) -> m a
Instances
#MonadThrow Source
class (Monad m) <= MonadThrow e m | m -> e where
The MonadThrow
type class represents those monads which support errors via
throwError
, where throwError e
halts, yielding the error e
.
An implementation is provided for ExceptT
, and for other monad transformers
defined in this library.
Laws:
- Left zero:
throwError e >>= f = throwError e
Members
throwError :: forall a. e -> m a
Instances
Re-exports from Control.Monad.Trans.Class
#MonadTrans Source
class 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
- Modules
- Control.
Comonad. Env - Control.
Comonad. Env. Class - Control.
Comonad. Env. Trans - Control.
Comonad. Store - Control.
Comonad. Store. Class - Control.
Comonad. Store. Trans - Control.
Comonad. Traced - Control.
Comonad. Traced. Class - Control.
Comonad. Traced. Trans - Control.
Comonad. Trans. Class - Control.
Monad. Cont - Control.
Monad. Cont. Class - Control.
Monad. Cont. Trans - Control.
Monad. Error. Class - Control.
Monad. Except - Control.
Monad. Except. Trans - Control.
Monad. List. Trans - Control.
Monad. Maybe. Trans - Control.
Monad. RWS - Control.
Monad. RWS. Trans - Control.
Monad. Reader - Control.
Monad. Reader. Class - Control.
Monad. Reader. Trans - Control.
Monad. State - Control.
Monad. State. Class - Control.
Monad. State. Trans - Control.
Monad. Trans. Class - Control.
Monad. Writer - Control.
Monad. Writer. Class - Control.
Monad. Writer. Trans