如何解决了解ST的量化和幻影类型
我正在尝试使用 Test.QuickCheck.Monadic
编写 monadic 测试代码。
模块提供了一个线束
monadicST :: Testable a => (forall s. PropertyM (ST s) a) -> Property
执行基于 ST
的测试和函数
run :: Monad m => m a -> PropertyM m a
将任何操作提升为测试单子。
act :: Monad m => a -> m ()
act = undefined
以下函数
st :: a -> Property
st = monadicST . run . act
编译失败:
• Couldn't match type ‘PropertyM m0 ()’
with ‘forall s. PropertyM (ST s) a0’
Expected type: PropertyM m0 () -> Property
Actual type: (forall s. PropertyM (ST s) a0) -> Property
• In the first argument of ‘(.)’,namely ‘monadicST’
In the expression: monadicST . run . act
In an equation for ‘st’: st = monadicST . run . act
但是这个
st' :: a -> Property
st' a = monadicST $ run $ act a
编译没有问题。
谁能解释一下?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。