Handle exceptions thrown in IO with fused-effects.
 
 
Go to file
Patrick Thomson 56b9169cd9 Forgot a language clause. 2019-10-29 14:56:11 -04:00
.github/workflows Add Actions-based CI. 2019-10-29 12:41:52 -04:00
src/Control consistent export lists 2019-10-29 12:53:24 -04:00
test Test `finally` in the presence of State.Strict and State.IORef. 2019-10-29 14:47:13 -04:00
.gitignore Add travis stuff since this is now a more prominent part of the ecosystem. 2019-10-14 13:24:55 -04:00
ChangeLog.md Update changelog. 2019-10-29 12:46:57 -04:00
LICENSE Extract from parent project. 2019-03-19 10:24:57 -04:00
README.md Adjust example in the README. 2019-10-29 14:50:52 -04:00
Setup.hs Extract from parent project. 2019-03-19 10:24:57 -04:00
cabal.project Add Control.Effect.Exception. 2019-10-29 12:22:20 -04:00
fused-effects-exceptions.cabal Forgot a language clause. 2019-10-29 14:56:11 -04:00
stack.yaml Add real version bound. 2019-04-08 13:14:38 -04:00

README.md

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:

λ runM (runState 'a' ((throwIO (userError "urk") `finally` put @Char 'z')
    `catch` (\(_ :: IOException) -> pure ())))
('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 Catch and Resource effects; these have 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.