我正在尝试使用Test.QuickCheck.Monadic
.
该模块提供了一个线束
monadicST :: Testable a => (forall s. PropertyM (ST s) a) -> Property
执行ST
-based 测试和一个函数
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
编译没有问题。
谁能解释一下?