如何编写触发quickCheck prop_xxx的函数?
|
我正在使用QuickCheck v1。这是一个简单的prop_xxx,定义如下:
prop_foo :: (Num a) =>[a] -> Bool
prop_foo xs = (reverse.reverse) xs == id xs
可以在GHCi中正确测试:
quickCheck prop_foo
但是,当我尝试将调用包装在一个函数中时:
f :: IO ()
f = quickCheck prop_foo
它报告了错误:
Ambiguous type variable `a\' in the constraints:
`Num a\' arising from a use of `prop_foo\' at Foo.hs:147:15-22
`Arbitrary a\'
arising from a use of `quickCheck\' at Foo.hs:147:4-22
Probable fix: add a type signature that fixes these type variable(s)
我可以提供类似的东西吗
instance Arbitrary Xxx where
arbitrary = ...
coarbitrary c = ...
非常感谢。
-
拉里
没有找到相关结果
已邀请:
1 个回复
铰齐插
毕竟,问题是:在您的原始版本中,
应该选择哪种类型的
来测试功能?
?
?还有吗该错误消息抱怨ѭ5是不明确的,即没有唯一的选择。