fused-effects-exceptions: Handle exceptions thrown in IO with fused-effects.

[ bsd3, control, control., library ] [ Propose Tags ]

Provides Resource and Catch effects capable of reacting to and catching GHC's dynamic exceptions.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.1.0, 0.2.0.0, 1.0.0.0, 1.1.0.0, 1.1.0.1
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), fused-effects (>=1.1), transformers (>=0.4 && <0.6) [details]
License BSD-3-Clause
Copyright 2019 Josh Vera, Patrick Thomson, and Rob Rix
Author Josh Vera, Patrick Thomson, and Rob Rix
Maintainer patrickt@github.com
Category Control
Home page https://github.com/fused-effects/fused-effects-exceptions#readme
Source repo head: git clone https://github.com/fused-effects/fused-effects-exceptions
Uploaded by robrix at 2020-07-13T15:27:51Z
Distributions
Downloads 3218 total (27 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for fused-effects-exceptions-1.1.0.0

[back to package description]

fused-effects-exceptions

Hackage BSD3 license Build Status

This package provides Control.Effect.Exception, a module that wraps the Control.Exception API from base with the vocabulary provided by the fused-effects library. These functions interact with GHC's support for dynamic exceptions, including functions like catch for exception handling and bracket for resource management.

Please be aware that injudicious use of these functions may provoke surprising interactions with carriers that thread a monadic state as a parameter, à la the Control.Carrier.State types provided by fused-effects. For example, a function like finally, which does not thread any state from its body to its handler block, may discard state writes in cleanup handlers:

discardsState :: IO Char
discardsState = execState 'a' ((throwIO (userError "urk") `finally` put @Char 'z')
    `catch` (\(_ :: IOException) -> pure ()))

Though the put @Char 'z' statement is evaluated, its effect is ultimately discarded; the result of executing the above is 'a'. If this behavior is a concern, a Control.Carrier.State.IORef carrier is provided, which fixes this issue given access to a MonadIO constraint. If it is not a concern (such as if the cleanup block is only run for its effects in IO), then the StateC carriers from fused-effects will suffice. For more information about the issues associated with this approach, consult Alexis King's excellent Demystifying MonadBaseControl.

Prior versions of this package provided a Catch effect; this has been excised in favor of the more-general Control.Effect.Exception, which provides more functionality without requiring any additional carriers beyond a Lift IO effect.