extensible-effects-5.0.0.0: An Alternative to Monad Transformers

Safe HaskellSafe
LanguageHaskell2010

Control.Eff.Exception

Description

Exception-producing and exception-handling effects

Synopsis

Documentation

newtype Exc e v Source #

Exceptions

exceptions of the type e; no resumption

Constructors

Exc e 
Instances
(MonadBase m m, LiftedBase m r) => MonadBaseControl m (Eff ((Exc e :: Type -> Type) ': r)) Source # 
Instance details

Defined in Control.Eff.Exception

Associated Types

type StM (Eff (Exc e ': r)) a :: Type #

Methods

liftBaseWith :: (RunInBase (Eff (Exc e ': r)) m -> m a) -> Eff (Exc e ': r) a #

restoreM :: StM (Eff (Exc e ': r)) a -> Eff (Exc e ': r) a #

Monad m => Handle (Exc e :: Type -> Type) r a (m (Either e a)) Source #

Given a callback, and an Exc request, respond to it.

Instance details

Defined in Control.Eff.Exception

Methods

handle :: (Eff r a -> m (Either e a)) -> Arrs r v a -> Exc e v -> m (Either e a) Source #

handle_relay :: (r ~ (Exc e ': r'), Relay (m (Either e a)) r') => (a -> m (Either e a)) -> (Eff r a -> m (Either e a)) -> Eff r a -> m (Either e a) Source #

respond_relay :: (a -> m (Either e a)) -> (Eff r a -> m (Either e a)) -> Eff r a -> m (Either e a) Source #

type StM (Eff ((Exc e :: Type -> Type) ': r)) a Source # 
Instance details

Defined in Control.Eff.Exception

type StM (Eff ((Exc e :: Type -> Type) ': r)) a = StM (Eff r) (Either e a)

exc :: Monad m => e -> m (Either e a) Source #

Throw an error

withException :: Monad m => a -> m (Either e a) Source #

Embed a pure value

type Fail = Exc () Source #

throwError :: Member (Exc e) r => e -> Eff r a Source #

Throw an exception in an effectful computation. The type is inferred.

throwError_ :: Member (Exc e) r => e -> Eff r () Source #

Throw an exception in an effectful computation. The type is unit, which suppresses the ghc-mod warning "A do-notation statement discarded a result of type"

die :: Member Fail r => Eff r a Source #

Makes an effect fail, preventing future effects from happening.

runError :: Eff (Exc e ': r) a -> Eff r (Either e a) Source #

Run a computation that might produce an exception.

runFail :: Eff (Fail ': r) a -> Eff r (Maybe a) Source #

Runs a failable effect, such that failed computation return Nothing, and Just the return value on success.

catchError :: Member (Exc e) r => Eff r a -> (e -> Eff r a) -> Eff r a Source #

Run a computation that might produce exceptions, and give it a way to deal with the exceptions that come up. The handler is allowed to rethrow the exception

onFail Source #

Arguments

:: Eff (Fail ': r) a

The fallible computation.

-> Eff r a

The computation to run on failure.

-> Eff r a 

Add a default value (i.e. failure handler) to a fallible computation. This hides the fact that a failure happened.

rethrowError :: Member (Exc e') r => (e -> e') -> Eff (Exc e ': r) a -> Eff r a Source #

Run a computation until it produces an exception, and convert and throw that exception in a new context.

liftEither :: Member (Exc e) r => Either e a -> Eff r a Source #

Treat Lefts as exceptions and Rights as return values.

liftEitherM :: (Member (Exc e) r, Lifted m r) => m (Either e a) -> Eff r a Source #

liftEither in a lifted Monad

liftMaybe :: Member Fail r => Maybe a -> Eff r a Source #

Lift a maybe into the Fail effect, causing failure if it's Nothing.

liftMaybeM :: (Member Fail r, Lifted m r) => m (Maybe a) -> Eff r a Source #

liftMaybe in a lifted Monad

ignoreFail :: Eff (Fail ': r) a -> Eff r () Source #

Ignores a failure event. Since the event can fail, you cannot inspect its return type, because it has none on failure. To inspect it, use runFail.