Handle exceptions thrown in IO with fused-effects.
 
 
Go to file
Joshua Potter 82d0d51810 Update version and fix https://github.com/NixOS/nixpkgs/issues/26561. 2022-04-02 10:57:45 -04:00
.github/workflows and make sure it runs everywhere we want it to 2021-04-07 18:30:09 -04:00
src/Control Update version and fix https://github.com/NixOS/nixpkgs/issues/26561. 2022-04-02 10:57:45 -04:00
test Add `UnliftIO` support, passing through stylish-haskell. 2022-04-01 09:51:25 -04:00
.envrc Add flake/HIE/README. 2022-04-01 09:51:21 -04:00
.gitignore Add flake/HIE/README. 2022-04-01 09:51:21 -04:00
.stylish-haskell.yaml Add the stylish-haskell config. 2020-07-03 13:39:05 -04:00
ChangeLog.md GHC 9 support. 2021-04-07 18:27:00 -04:00
LICENSE Extract from parent project. 2019-03-19 10:24:57 -04:00
README.lhs Symlink the README. 2019-11-01 11:23:13 -04:00
README.md Add flake/HIE/README. 2022-04-01 09:51:21 -04:00
Setup.hs Extract from parent project. 2019-03-19 10:24:57 -04:00
cabal.project Bump to 1.1. 2020-07-08 11:09:01 -04:00
cabal.project.ci Add a CI-specific cabal.project file. 2020-07-13 11:12:52 -04:00
default.nix Add flake-compat. 2022-04-01 11:06:36 -04:00
flake.lock Add flake-compat. 2022-04-01 11:06:36 -04:00
flake.nix Update version and fix https://github.com/NixOS/nixpkgs/issues/26561. 2022-04-02 10:57:45 -04:00
fused-effects-exceptions.cabal Update version and fix https://github.com/NixOS/nixpkgs/issues/26561. 2022-04-02 10:57:45 -04:00
hie.yaml Add flake/HIE/README. 2022-04-01 09:51:21 -04:00

README.md

fused-effects-exceptions

BSD3 license

This fork provides Control.Effect.Exception[.UnliftIO], a module that wraps the Control.Exception and UnliftIO.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.