bluefin-algae-0.1.0.0: Algebraic effects and named handlers in Bluefin.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Bluefin.Exception.Dynamic

Description

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

Synopsis

Documentation

data DynExn (ex :: Effects) Source #

Capability to catch and throw dynamic exceptions.

runDynExn :: (forall ex. DynExn ex -> Eff ex a) -> a Source #

Run a computation with only access to dynamic exceptions.

ioeToDynExn :: IOE io -> DynExn io Source #

Refine an IOE capability to a DynExn.

throw :: (Exception e, ex :> es) => DynExn ex -> e -> Eff es a Source #

Throw an exception.

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 run: acquire 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 cleanup: run 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 cleanup: run a computation, and if an exception is thrown, cleanup, then rethrow the exception.

throwIO :: (Exception e, io :> es) => IOE io -> e -> Eff es a Source #

throw with an IOE capability.

catchIO :: (Exception e, io :> es) => IOE io -> Eff es a -> (e -> Eff es a) -> Eff es a Source #

catch with an IOE capability.