[Haskell-cafe] Quick-check: how to generate arbitrary complex data?

Aleksey Uymanov s9gf4ult at gmail.com
Sat Jul 13 10:56:52 CEST 2013


On Sat, 13 Jul 2013 10:10:39 +0200
martin <martin.drautzburg at web.de> wrote:

> This requires HashedList to be a new type, right? So far my code only
> used type synonyms.
> 
> Does this mean I have to convert type synonyms into types in order to
> use QuickCheck?
> 
> Does this mean I have to "plan for QuickCheck" when I design my types?

You can still create your own Gen manually and have several generators
for different 'types'.

You will need to use 'forAll' combinator to perform the testing like this:


data A
type ListA = [A]
type OtherListA = [A]

genListA :: Gen ListA

genOtherListA :: Gen OtherListA

checkListA :: ListA -> Property

checkOtherListA :: OtherListA -> Property

prop1 = forAll genListA checkListA
prop2 = forAll genOtherListA checkOtherListA 

-- 
Aleksey Uymanov <s9gf4ult at gmail.com>



More information about the Haskell-Cafe mailing list