Fix general bracket for ExceptT/ErrorT (#60)
* Demonstrate broken ExceptT instance for MonadMask * Simplify generalBracket so it works for ExceptT The previous type signature was in fact invalid, as it did not allow for a valid instance for ExceptT (et al). In particular, in the case of a non-exceptional Left result, neither the release nor cleanup functions could be used, since: * No result value was available for release * No SomeException value was available for cleanup It appears that this less pleasing version of generalBracket is the only one that works for all the types we care about. Furthermore: once we accept this, we are now forced to perform some discarding of updated state and Monoid written values in the StateT, WriterT, and RWST instances. This seems inherent to making things compatible with ExceptT. An alternative to this is to simply remove the ExceptT and ErrorT instances, but that's contrary to what many users want it seems. * Doc cleanups @RyanGIScott's review
Showing
- exceptions.cabal 2 additions, 1 deletionexceptions.cabal
- src/Control/Monad/Catch.hs 41 additions, 40 deletionssrc/Control/Monad/Catch.hs
- src/Control/Monad/Catch/Pure.hs 3 additions, 1 deletionsrc/Control/Monad/Catch/Pure.hs
- tests/Control/Monad/Catch/Tests.hs 15 additions, 2 deletionstests/Control/Monad/Catch/Tests.hs
Loading
Please register or sign in to comment