Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Dynamic exceptions
This is the vanilla exception mechanism from IO
.
Use this module to handle exceptions from external (non-bluefin) APIs.
Another motivation is to serve as a principled (experimental) framework
for resource management with bracket
.
The core Bluefin API exposes a bracket
in Bluefin.Eff
which (intentionally) weakens the scoping of scoped exceptions in
Bluefin.Exception.
This module is an experiment for a world where
- scoped exceptions are truly scoped (unlike Bluefin.Exception);
- the capability to catch and throw dynamic exceptions is explicit
(unlike
bracket
in Bluefin.Eff).
Synopsis
- data DynExn (ex :: Effects)
- runDynExn :: (forall ex. DynExn ex -> Eff ex a) -> a
- ioeToDynExn :: IOE io -> DynExn io
- throw :: (Exception e, ex :> es) => DynExn ex -> e -> Eff es a
- catch :: (Exception e, ex :> es) => DynExn ex -> Eff es a -> (e -> Eff es a) -> Eff es a
- bracket :: ex :> es => DynExn ex -> Eff es a -> (a -> Eff es ()) -> (a -> Eff es b) -> Eff es b
- finally :: ex :> es => DynExn ex -> Eff es a -> Eff es () -> Eff es a
- onException :: ex :> es => DynExn ex -> Eff es a -> Eff es () -> Eff es a
- throwIO :: (Exception e, io :> es) => IOE io -> e -> Eff es a
- catchIO :: (Exception e, io :> es) => IOE io -> Eff es a -> (e -> Eff es a) -> Eff es a
Documentation
runDynExn :: (forall ex. DynExn ex -> Eff ex a) -> a Source #
Run a computation with only access to dynamic exceptions.
catch :: (Exception e, ex :> es) => DynExn ex -> Eff es a -> (e -> Eff es a) -> Eff es a Source #
Catch an exception.
bracket :: ex :> es => DynExn ex -> Eff es a -> (a -> Eff es ()) -> (a -> Eff es b) -> Eff es b Source #
: bracket
ex acquire release runacquire
a resource, run
a computation depending on it,
and finally relase
the resource even if run
threw an exception.
finally :: ex :> es => DynExn ex -> Eff es a -> Eff es () -> Eff es a Source #
: finally
ex run cleanuprun
a computation, then cleanup
even if
run
threw an exception.
onException :: ex :> es => DynExn ex -> Eff es a -> Eff es () -> Eff es a Source #
: onException
ex run cleanuprun
a computation, and if an exception is thrown,
cleanup
, then rethrow the exception.