1
我正在使用QuickCheck v1。下面是如下面所定义的简单prop_xxx:如何编写一个函数来激发quickCheck prop_xxx?
prop_foo :: (Num a) =>[a] -> Bool
prop_foo xs = (reverse.reverse) xs == id xs
这可以在GHCI正确地进行测试: 快速检查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)
要我提供的东西LIK e
instance Arbitrary Xxx where
arbitrary = ...
coarbitrary c = ...
非常感谢。
- 拉里
准确地说,只是'ghci'默认使用'Integer'。这就是为什么'ghci'没有抱怨,这当然是为了方便。没有? – Tarrasch 2011-04-21 08:39:04