lundi 19 février 2018

How do I write a QuickCheck property that arbitrarily modifies its arbitrary input?

Suppose I would like to verify isSubsequenceOf. I then need to generate my ys from some random xs by arbitrarily adding or removing some elements, and then verify the property. Using sublistOf, I would go like this:

\xs -> sublistOf xs `isSubsequenceOf` xs

— Except that this does not type check.

Unfortunately I don't understand the design of the QuickCheck library overall, and even such seemingly trivial cases puzzle me a big deal. Do I have to spell out a full-blown monadic device of type Gen Result? It kind of defies the purpose of the abstraction.

Aucun commentaire:

Enregistrer un commentaire