[Haskell-cafe] Quick Question for QuickCheck2
as at 0xff.ath.cx
Mon Aug 30 11:23:39 EDT 2010
You can create a wrapper with a newtype and then define an instance for that.
newtype Char2 = Char2 Char
instance Arbitrary Char2 where
arbitrary = ...
You'll have to do some wrapping and unwrapping when calling your
properties to get/set the underlying Char, but this is probably the
easiest way to 'constrain' the possible arbitrary results when the
default instance for Char can be "too much."
On Mon, Aug 30, 2010 at 10:12 AM, Sebastian Höhn
<sebastian.hoehn at googlemail.com> wrote:
> perhaps I am just blind or is it a difficult issue: I would like to
> generate Char values in a given Range for QuickCheck2. There is this
> simple example from the haskell book:
> instance Arbitrary Char where
> arbitrary = elements (['A'..'Z'] ++ ['a' .. 'z'] ++ " ~!@#$%^&*()")
> This does not work in QuickCheck2 since the instance is already
> defined. How do I achieve this behaviour in QC2?
> Thanks for helping.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe