14
I have a higher-order function that I want to test, and one of the properties I want to test is what it does with the functions that are passed in. For purposes of illustration, here is a contrived example:
gen :: a -> ([a] -> [a]) -> ([a] -> Bool) -> a
The idea is roughly that this is an example generator. I'm going to start with a single a, create a singleton list of [a], then make new lists of [a] until a predicate tells me to stop. A call might look like this:
gen init next stop
where
init :: a
next :: [a] -> [a]
stop :: [a] -> Bool
Here's the property I'd like to test:
On any call to
gen init next stop,genpromises never to pass an empty list tonext.
Can I test this property using QuickCheck, and if so, how?