Skip to content
Snippets Groups Projects
Commit 7ec3240e authored by Michael Snoyman's avatar Michael Snoyman Committed by Ryan Scott
Browse files

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
parent 41b67986
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment