Module
Control.Monad.Except.Checked
- Package
- purescript-checked-exceptions
- Repository
- natefaubion/purescript-checked-exceptions
Extensible checked exceptions with polymorphic variants
This module provides helpers for using Variant
with ExceptT
. When
combined, we get a mechanism for extensible, checked exceptions. That
is, exceptions can be defined and used anywhere, and handled as needed.
Handling an exception eliminates it from the type, giving us proof
that it no longer occurs.
#handleError Source
handleError :: forall a rl excOut excIn excHandled handlers m. RowToList handlers rl => VariantMatchCases rl excHandled (ExceptV excOut m a) => Union excHandled excOut excIn => Monad m => Record handlers -> ExceptV excIn m a -> ExceptV excOut m a
Catches and eliminates exceptions given a record of handlers. Unhandled exceptions are re-propragated. Record fields map to the label for the exception being handled.
An example for handling HTTP exceptions might be:
request # handleError
{ httpNotFound: \_ -> ...
, httpServerError: \error -> ...
}
- Modules
- Control.
Monad. Except. Checked