Bugfix for QuickCheck 1.1.0.0

Johan Tibell johan.tibell at gmail.com
Sun Aug 31 13:53:11 EDT 2008


On Sun, Aug 31, 2008 at 10:28 AM, Patrick Perry <patperry at stanford.edu> wrote:
> 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'

Could you explain how this works? It's not entirely clear to me.

Thanks.

-- Johan


More information about the Libraries mailing list