Control.Effect.Error
data Error e :: Effect where Source #
The Error e effect allows throwing and catching errors of type e.
Error e
Error
e
Handlers should obey the law catch (throw x) f ≡ pure (f x).
catch (throw x) f
catch
throw
pure (f x)
pure
Constructors
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.
catch m f
m
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.
Left
Right