Module
Error.Control
- Package
- purescript-errorcontrol
- Repository
- LukaJCB/purescript-errorcontrol
#ErrorControl Source
class (MonadThrow e f, Monad g) <= ErrorControl f g e | f -> e, f -> g where
A type class for principled Error handling.
ErrorControl allows to represent already handled errors in the type system
by switching to an unexceptional type constructor g
.
Find more here: https://lukajcb.github.io/blog/functional/2018/04/15/rethinking-monaderror.html
Should respect the following laws:
- Catch:
controlError (throwError e) f === f e
- Pure:
controlError (pure a) f === pure a
- No Errors in g:
handleBlunder (accept ga) f === ga
Members
controlError :: forall a. f a -> (e -> g a) -> g a
accept :: g ~> f
Instances
ErrorControl (Either e) Identity e
(Monad f) => ErrorControl (ExceptT e f) f e
(ErrorControl f g e) => ErrorControl (StateT s f) (StateT s g) e
#intercept Source
intercept :: forall a e g f. ErrorControl f g e => f a -> (e -> a) -> g a
- Modules
- Error.
Control