应该传递给以下代码的 CoArbitrary 的 ex 是什么?
如何使用 Test.QuickCheck.Function 中的 Function 来表示命题中的 f 和 g?
写是正确的,如果不是,怎么写?
其中类型 = [f, g] :: [函数]
变体可以接受 Function 吗?据我所知,生成函数经常使用 >< 或 QuickCheck 源代码中所述的变体
错误:
<interactive>:1:12:
No instance for (Eq (b0 -> b0))
arising from a use of `prop_commutative'
Possible fix: add an instance declaration for (Eq (b0 -> b0))
In the first argument of `quickCheck', namely `prop_commutative'
In the expression: quickCheck prop_commutative
In an equation for `it': it = quickCheck prop_commutative
[更新]
另一种写法模仿函数中的示例,在 ghci 中的 '=' 处解析错误 let prop_commutative (Fun _ f) (Fun _ g) = (f.g) == (g.f)
可以运行
编码:
import Test.QuickCheck.Function
import Test.QuickCheck.Gen
import Test.QuickCheck
let prop_commutative (Fun _ f) (Fun _ g) = (f.g) == (g.f)
main = quickCheck prop_commutative