[QuickCheck] Bug with Small and Positive types

Anders Persson anders.cj.persson at gmail.com
Sun May 4 05:26:52 BST 2014


The Arbitrary instance for Small does not use the arbitrary for the inner type. Instead it uses choose.
As a workaround you can switch the order of the modifiers:

>>> sample (arbitrary :: Gen (Positive (Small Int)))
Positive {getPositive = Small {getSmall = 1}}
Positive {getPositive = Small {getSmall = 3}}
Positive {getPositive = Small {getSmall = 2}}
Positive {getPositive = Small {getSmall = 3}}

/Anders

On 4 maj 2014, at 05:24, Bryan O'Sullivan <bos at serpentine.com> wrote:

> Not exactly expected behaviour: I get values that are not positive.
> 
> >>> sample (arbitrary :: Gen (Small (Positive Int)))
> Small {getSmall = Positive {getPositive = 0}}
> Small {getSmall = Positive {getPositive = -1}}
> Small {getSmall = Positive {getPositive = 2}}
> _______________________________________________
> QuickCheck mailing list
> QuickCheck at projects.haskell.org
> http://projects.haskell.org/cgi-bin/mailman/listinfo/quickcheck

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4136 bytes
Desc: not available
URL: <http://projects.haskell.org/pipermail/quickcheck/attachments/20140504/0e5c529f/attachment.bin>


More information about the QuickCheck mailing list