[Haskell-cafe] HTF & Quickcheck
Simon Hengel
sol at typeful.net
Tue Dec 18 19:04:21 CET 2012
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