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

Instances

#intercept Source

intercept :: forall a e g f. ErrorControl f g e => f a -> (e -> a) -> g a

#trial Source

trial :: forall a e g f. ErrorControl f g e => Monad f => f a -> g (Either e a)

#absolve Source

absolve :: forall a e g f. ErrorControl f g e => Monad f => g (Either e a) -> f a

#assure Source

assure :: forall a e g f. ErrorControl f g e => Monad f => g a -> (a -> Maybe e) -> f a
Modules
Error.Control