I am testing a function called extractions that works on any list.
extractions :: [a] -> [(a,[a])] extractions [] = [] extractions l = extract l [] where extract [] _ = [] extract (x:xs) prev = (x, prev++xs) : extract xs (x : prev)
I want to check it, for example, with
import Test.QuickCheck.Batch prop_len l = length l == length (extractions l) main = runTests "extractions" defOpt [run prop_len]
But this does not compile; I have to specify the type for run or prop_len , because QuickCheck cannot generate [a] , it must generate something specific. So I chose Int :
main = runTests "extractions" defOpt [r prop_len] where r = run :: ([Int] -> Bool) -> TestOptions -> IO TestResult
Is there a way to get QuickCheck to select a for me instead of pointing it to run type?
type-inference haskell testing quickcheck
Nathan shively-sanders
source share