[Haskell-cafe] class Arbitrary in quickcheck

Ozgur Akgun ozgurakgun at gmail.com
Wed May 5 04:01:11 EDT 2010


your quick check property (in a different way of writing) is the following:

prop_1 :: Maybe Double -> Bool
prop_1 v = v == v

but what you want is actually the following:

prop_2 :: Maybe Double -> Maybe Double -> Bool
prop_2 v1 v2 = v2 == v2

if I understood the problem correctly, using prop_2 should solve it. just
run verboseCheck<http://hackage.haskell.org/packages/archive/QuickCheck/1.1.0.0/doc/html/Test-QuickCheck.html#v:verboseCheck>on
these two and observe the results.

Best,



On 5 May 2010 08:47, Tim Docker <twd2 at dockerz.net> wrote:

> I've notice a behaviour of quickcheck that is unexpected to me. With
> this code:
>
> import Test.QuickCheck
>
> main = check myconfig
>     ((\v -> v == v) :: (Maybe Double,Maybe Double) -> Bool)
>
> myconfig = defaultConfig{configMaxTest=100000,
>                         configEvery = \n args -> show n ++ ":\n"
>                                                  ++ unlines args}
>
> I am relying on the default Arbitrary instances to generate pairs of
> maybe doubles. But to my surprise, all of the pairs have these patterns:
>
>    (Just _ Just _)
>    (Nothing, Nothing)
>
> I never see patterns:
>
>    (Just _, Nothing)
>    (Nothing, Just _)
>
> Why is this the case?
>
> Thanks,
>
> Tim
>
>
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100505/c27a12f3/attachment.html


More information about the Haskell-Cafe mailing list