transformers-0.5.5.0: Concrete functor and monad transformers

Description

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.

Synopsis

type Except e = ExceptT e Identity Source #

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.

except :: Either e a -> Except e a Source #

Constructor for computations in the exception monad. (The inverse of runExcept).

runExcept :: Except e a -> Either e a Source #

Extractor for computations in the exception monad. (The inverse of except).

mapExcept :: (Either e a -> Either e' b) -> Except e a -> Except e' b Source #

Map the unwrapped computation using the given function.

• runExcept (mapExcept f m) = f (runExcept m)

withExcept :: (e -> e') -> Except e a -> Except e' a Source #

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

newtype ExceptT e m a Source #

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

 ExceptT (m (Either e a))
Instances

runExceptT :: ExceptT e m a -> m (Either e a) Source #

The inverse of ExceptT.

mapExceptT :: (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b Source #

Map the unwrapped computation using the given function.

• runExceptT (mapExceptT f m) = f (runExceptT m)

withExceptT :: Functor m => (e -> e') -> ExceptT e m a -> ExceptT e' m a Source #

Transform any exceptions thrown by the computation using the given function.

# Exception operations

throwE :: Monad m => e -> ExceptT e m a Source #

Signal an exception value e.

• runExceptT (throwE e) = return (Left e)
• throwE e >>= m = throwE e

Arguments

 :: Monad m => ExceptT e m a the inner computation -> (e -> ExceptT e' m a) a handler for exceptions in the inner computation -> ExceptT e' m a

Handle an exception.

• catchE h (lift m) = lift m
• catchE h (throwE e) = h e

# Lifting other operations

liftCallCC :: CallCC m (Either e a) (Either e b) -> CallCC (ExceptT e m) a b Source #

Lift a callCC operation to the new monad.

liftListen :: Monad m => Listen w m (Either e a) -> Listen w (ExceptT e m) a Source #

Lift a listen operation to the new monad.

liftPass :: Monad m => Pass w m (Either e a) -> Pass w (ExceptT e m) a Source #

Lift a pass operation to the new monad.