HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduletransformers-0.6.1.1Haskell2010

Control.Monad.Trans.Except

This monad transformer extends a monad with the ability to throw exceptions.

A sequence of actions terminates normally, producing a value, only if none of the actions in the sequence throws an exception. If one throws an exception, the rest of the sequence is skipped and the composite action exits with that exception.

If the value of the exception is not required, the variant in Control.Monad.Trans.Maybe may be used instead.

  • 2 types
  • 15 values

The Except monad

5 declarations
typetype Except e = ExceptT e Identity
#

The parameterizable exception monad.

Computations are either exceptions or normal values.

The return function returns a normal value, while >>= exits on the first exception. For a variant that continues after an error and collects all the errors, see Errors.

valuewithExcept :: (e -> e') -> Except e a -> Except e' a
#

Transform any exceptions thrown by the computation using the given function (a specialization of withExceptT).

The ExceptT monad transformer

4 declarations
newtypenewtype ExceptT e (m :: Type -> Type) a
#

A monad transformer that adds exceptions to other monads.

ExceptT constructs a monad parameterized over two things:

  • e - The exception type.

  • m - The inner monad.

The return function yields a computation that produces the given value, while >>= sequences two subcomputations, exiting on the first exception.

Constructors

Instances25Generic1, MonadTrans, Monad, Functor, MonadFix, MonadFail, …

Exception operations

5 declarations
valuefinallyE :: Monad m => ExceptT e m a -> ExceptT e m () -> ExceptT e m a
#

finallyE a b executes computation a followed by computation b, even if a exits early by throwing an exception. In the latter case, the exception is re-thrown after b has been executed.

Lifting other operations

3 declarations