Make Test.QuickCheck.Batch use the default type for testing list functions

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?

+6
type-inference haskell testing quickcheck
source share
1 answer

quickcheck manual says no:

Properties must have monomorphic types. Polymorphic properties, such as those listed above, should be limited to the specific type that will be used for testing. This is conveniently done by specifying the types of one or more arguments in

where types = (x1 :: t1, x2 :: t2, ...)

paragraph...

+7
source share

All Articles