[QuickCheck] instance Functor Positive

Nick Smallbone nicsma at chalmers.se
Mon Nov 4 19:03:28 GMT 2013


Hi Henning,

I don't see any reason for the modifiers not to have a Functor
instance so I have just added that.

However, shrinking ought to take care of finding simple
counterexamples - it should be enough just to write 'quickCheck wrong'
in your case. I have looked at the Arbitrary instance for Rational and
the shrinking behaviour was really quite bad - it was only shrinking
to the nearest integer and not trying anything smaller than that.  I
have rejigged the shrinking code for RealFrac to be more aggressive so
now you shouldn't need the Functor instances after all :)
For Rational, it will try to shrink to a small integer; for Float and
Double, it will also try non-integral values.

Nick

On Monday 04 November, 2013 at 05:44 pm, Henning Thielemann wrote:
> 
> I would like to have Functor instances for NonEmptyList, Positive
> and maybe all other modifier types.
> 
> My application: I have a function for Fractional types that is
> wrong. I want to have simple counterexamples, e.g. ones with small
> integer numbers. To this end I want to write:
> 
> wrong :: NonEmptyList (Positive Rational) -> Bool
> 
> quickCheck $ wrong . fmap (fmap fromInteger)
> 
> 
> Is this reasonable?
> 
> _______________________________________________
> QuickCheck mailing list
> QuickCheck at projects.haskell.org
> http://projects.haskell.org/cgi-bin/mailman/listinfo/quickcheck



More information about the QuickCheck mailing list