Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
Documentation
throwError :: (Member (Error exc) sig, Carrier sig m) => exc -> m a Source #
Throw an error, escaping the current computation up to the nearest catchError
(if any).
run (runError (throwError a)) == Left @Int @Int a
catchError :: (Member (Error exc) sig, Carrier sig m) => m a -> (exc -> m a) -> m a Source #
Run a computation which can throw errors with a handler to run on error.
Errors thrown by the handler will escape up to the nearest enclosing catchError
(if any).
run (runError (pure a `catchError` pure)) == Right a
run (runError (throwError a `catchError` pure)) == Right @Int @Int a
run (runError (throwError a `catchError` (throwError @Int))) == Left @Int @Int a
runError :: (Carrier sig m, Effect sig, Monad m) => Eff (ErrorC exc m) a -> m (Either exc a) Source #