Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active February 10, 2017 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/9d1cce0bd3cf97f8da0cae13d9e7f0f6 to your computer and use it in GitHub Desktop.
Save deque-blog/9d1cce0bd3cf97f8da0cae13d9e7f0f6 to your computer and use it in GitHub Desktop.
forAll :: (Show a, Testable t) => Gen a -> Shrink a -> (a -> t) -> Property
forAll argGen shrink prop =
Property $ Gen $ \rand -> -- Create a new property that will
let (rand1, rand2) = split rand -- Split the generator in two
arg = runGen argGen rand1 -- Use the first generator to produce an arg
tree = resultTree shrink arg prop -- Enrich the sub-property result tree
in runProp tree rand2 -- Run the property with the second generator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment