为什么ExceptT有MonadMask实例? [英] Why is there a MonadMask instance for ExceptT?

查看:220
本文介绍了为什么ExceptT有MonadMask实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在前面的问题中,我问过

为什么没有MonadMask实例对于ExceptT?



并获得了许多令人信服的答案,包括来自图书馆作者,为什么不能存在合法实例。



截至2018年2月,例外的确现在有一个 MonadMask for ExceptT



所以现在我问的是完全相反的问题:为什么我以前的问题的答案不正确?

解决方案

例外 库在文档中有答案:


该方法在该库的版本0.9.0中添加。以前,在这个模块中实现像括号 finally 这样的函数是基于掩码 uninterruptibleMask 函数,但不允许某些类别的变换器具有 MonadMask ExceptT 这样的退出点转换器)。如果您是图书馆作者,您现在需要提供此方法的实施...


(注意:类型 generalBracket 在0.10中更改,请勿使用0.9)。


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?

解决方案

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 and finally in this module were based on the mask and uninterruptibleMask functions only, disallowing some classes of transformers from having MonadMask instances (notably multi-exit-point transformers like ExceptT). 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).

这篇关于为什么ExceptT有MonadMask实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆