eff-0.0.0.0
Safe HaskellNone
LanguageHaskell2010

Control.Effect.Error

Synopsis

Documentation

data Error e :: Effect where Source #

The Error e effect allows throwing and catching errors of type e.

Handlers should obey the law catch (throw x) fpure (f x).

Constructors

Throw :: e -> Error e m a 
Catch :: Eff (Error e ': effs) a -> (e -> Eff effs a) -> Error e (Eff effs) a 

throw :: Error e :< effs => e -> Eff effs a Source #

Raises an error of type e.

catch :: Error e :< effs => Eff (Error e ': effs) a -> (e -> Eff effs a) -> Eff effs a Source #

catch m f executes m. If it raises an error e, the computation aborts to the point of the call to catch, and it resumes by executing f e.

runError :: forall e a effs. Eff (Error e ': effs) a -> Eff effs (Either e a) Source #

Handles an Error effect. Returns Left if the computation raised an uncaught error, otherwise returns Right.