问题
In a previous question, I asked
Why is there no MonadMask instance for ExceptT?
and got a number of compelling answers, including from the library author, why there cannot exist a lawful instance.
As of February 2018, the exceptions library does now have an instance of MonadMask for ExceptT.
So now I'm asking the exact opposite question: Why are the answers to my previous question incorrect?
回答1:
The documentation of the exceptions library has the answer in its docs:
This method was added in version 0.9.0 of this library. Previously, implementation of functions like
bracket
andfinally
in this module were based on themask
anduninterruptibleMask
functions only, disallowing some classes of transformers from havingMonadMask
instances (notably multi-exit-point transformers likeExceptT
). If you are a library author, you'll now need to provide an implementation for this method...
(Note: the type of generalBracket
were changed in 0.10, don't use 0.9).
来源:https://stackoverflow.com/questions/50318471/why-is-there-a-monadmask-instance-for-exceptt