[QuickCheck] 2.7 is a huge pain in the ass

Nick Smallbone nicsma at chalmers.se
Mon May 5 10:30:10 BST 2014


Hi Bryan,

On Monday 28 April, 2014 at 09:53 am, Bryan O'Sullivan wrote:
> There have been a few things.
> 
> Turning Property into a newtype led to completely mysterious breakages,
> where it is completely unclear from the type errors why code that used to
> work no longer does.
> 
> Here's the first example:
> https://github.com/bos/text/commit/47844197b09efe9b36f3d89855c0dc05079046b3
> 
> I had absolutely no idea what was wrong above, I just got lucky in finding
> a fix.
> 
> This is a more complex version of the same problem, where I finally had to
> break down and actually read the QuickCheck source to figure out why my
> code had suddenly broken:
> https://github.com/bos/text/commit/be120c5a83137ab83b8de7ec2221e1932ad5b1f5
> 
> Yet another version of the same thing:
> https://github.com/bos/statistics/commit/9a973b54747fb7250916cb7c5c96c8c874fac046

I do sympathise, but if you'd asked on the mailing list I would've
helped you fix these. The right fix is less invasive than your one,
BTW - since Gen Property is an instance of Testable, you just have to
wrap the final expression of the do-block in a return, like so:

  t_utf8_incr = do
    Positive n <- arbitrary
    return $ forAll genUnicode $ recode n `eq` id

The same fix should work for your other two properties. Probably I
should put an example of this in the documentation. By the way, do you
really not want to include n in the counterexample (which is what will
happen when you use monadic bind instead of forAll to generate n)?

> Code renaming:
> https://github.com/bos/statistics/commit/d0ce236e690d3e3ba80248c9dc02a04582a2bc5a

On reflection I can see that this change might be a bit gratuitous.
I think the name printTestCase is terrible and decided to rename it
now before it becomes too widely-used (there are currently 18 packages
on Hackage that use it). The old name still works, it's just
deprecated, and it won't be going away for a good couple of years.

Nick



More information about the QuickCheck mailing list