我正在测试一个名为提取的函数,它可以在任何列表上运行。
extractions :: [a] -> [(a,[a])]
extractions [] = []
extractions l = extract l []
where extract [] _ = []
extract (x:xs) prev = (x, prev++xs) : extract xs (x : prev)
我想测试它,例如,
import Test.QuickCheck.Batch
prop_len l = length l == length (extractions l)
main = runTests "extractions" defOpt [run prop_len]
但这不会编译;我必须为run
or提供一个类型prop_len
,因为 QuickCheck 不能生成[a]
,它必须生成一些具体的东西。所以我选择了Int
:
main = runTests "extractions" defOpt [r prop_len]
where r = run :: ([Int] -> Bool) -> TestOptions -> IO TestResult
有没有办法让 QuickChecka
为我选择而不是在类型中指定它run
?