Proposal: free shrinking with QuickCheck

Reid Draper reiddraper at gmail.com
Fri Nov 22 19:18:01 UTC 2013


On Nov 22, 2013, at 12:02 PM, Bryan O'Sullivan <bos at serpentine.com> wrote:

> 
> On Thu, Nov 21, 2013 at 4:27 PM, Reid Draper <reiddraper at gmail.com> wrote:
> I originally sent this message to the QuickCheck mailing list,
> but haven't heard anything in a while, and realized there are
> only ten subscribers. Below is the original message, any feedback
> appreciated.
> 
> I don't love this idea on first reading. The move to switch to generating a rose tree seems rather intrusive and like it could put a lot of complexity right in the paths of developers. That being said, I'd be interested in seeing the idea fleshed out to the point of determining whether my worry has any teeth - could the end-user writing of an Arbitrary instance remain unaffected in practice?

I'll take a stab at a minimal implementation. The goal would certainly be for users to be able to simply delete their `shrink` function. If they were previously using the default (shrink _ = []), they'd then get shrinking for free. For those looking for more motivation, take a look at how boilerplate shrink implementations end up being in practice. Further, care must be given to respect any implicit constraints during shrinking, that are respected during generation. For example, when generating with `choose 10 20`, you must never shrink to a value below 10. This would all be taken care of using the proposed method.

critbit: https://github.com/bos/critbit/blob/master/tests/Properties/Common.hs#L32-L33
a boolean logic solver: https://github.com/reiddraper/haskell-logic/blob/master/logic.hs#L89-L106
pandoc, which doesn't have shrinking, conceivably it'd be quite tedious: https://github.com/jgm/pandoc/blob/master/tests/Tests/Arbitrary.hs

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20131122/70b5868f/attachment.html>


More information about the Libraries mailing list