Test.QuickCheck.Modifiers wrappers (from Test.QuickCheck.Modifiers , if they are not implicitly replicated) can be used as follows:
prop_Myfunc :: [Int] -> (NonNegative Int, NonNegative Int) -> Bool prop_Myfunc ints (NonNegative i, NonNegative j) = ints !! i == ints !! j
You can treat SomeWrapper a as a with a modified distribution. For example, NonNegative a provides a >= 0 . After the shell has been generated, the value can be obtained using pattern matching or explicit access ( getNonNegative in this case).
As for limiting the top edge of your indexes, I think this is not possible with wrappers (in the Haskkell system, type parameterization with a value is impossible, the length of the list in this case). However, with the ==> operator ==> you can add an arbitrary logical constraint for your test:
prop_Myfunc ints (NonNegative i, NonNegative j) = i < l && j < l ==> ints !! i == ints !! j where l = length ints
It works differently: when the condition is not true, it just discards the current test case. But be careful: if there are too many thrown cases (the condition is too restrictive), the test becomes much less useful. Lossless behavior is often achieved using shrink ing test data, but that's a whole other topic.
Yuuri source share