[Haskell-cafe] HTF & Quickcheck
graham at fatlazycat.com
graham at fatlazycat.com
Tue Dec 18 19:38:39 CET 2012
Thanks, how does using /= not cause test failures ? Just the sample rate
will be high enough ?
On Tue, Dec 18, 2012, at 06:04 PM, Simon Hengel wrote:
> On Tue, Dec 18, 2012 at 05:25:41PM +0000, graham at fatlazycat.com wrote:
> > Are there any libraries that define various common generators ?
> >
> > What would be the cleanest way to define two positive integers below
> > 1000 that are different ? Seems relatively easy with conditionals.
>
> You can still use (==>) to ensure that two numbers are different. I
> would use something like this:
>
> newtype Small = Small Int
> deriving Show
>
> instance Arbitrary Small where
> arbitrary = Small . (`mod` 1000) <$> arbitrary
>
> prop_foo (Small x) (Small y) = x /= y ==> ...
>
> Cheers,
> Simon
More information about the Haskell-Cafe
mailing list