Bugfix for QuickCheck 1.1.0.0

Patrick Perry patperry at stanford.edu
Sun Aug 31 13:28:32 EDT 2008


It's been a week and no one has objected.  I'm interpreting your  
silence on the matter as consent.  Could someone with commit access  
please add the patch and bump the version number for QuickCheck?

If you haven't read the ticket, there is a bug in Quickcheck.   
Currently, this property:

prop_f (f :: Double -> Int) = let
	x = f (-3.4)
	in x >= 0 || x < 0

will cause QuickCheck to hang.  The attached patch fixes the problem.   
It changes this:

variant :: Int -> Gen a -> Gen a
variant v (Gen m) = Gen (\n r -> m n (rands r !! (v+1))
	where
		rands r0 = r1 : rands r2 where (r1, r2) = split r0

to this:

variant :: Int -> Gen a -> Gen a
variant v (Gen m) = Gen (\n r -> m n (rands r v))
	where
		rands r0 0 = r0
		rands r0 n = let (r1,r2) = split r0
			(n',s)  = n `quotRem` 2
			in case s of
				0 -> rands r1 n'
				_ -> rands r2 n'


Thanks in advance to whoever adds the fix.


Patrick


On Aug 21, 2008, at 9:20 PM, Patrick Perry wrote:

> Hi everyone,
>
> I've put in a proposal that fixes a bug in QuickCheck 1.1.0.0.
>
> http://hackage.haskell.org/trac/ghc/ticket/2535
>
> Thanks,
>
>
> Patrick
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries



More information about the Libraries mailing list