Some QuickCheck Instances
Dominic Steinitz
dominic.steinitz at blueyonder.co.uk
Sat Oct 25 06:49:15 EDT 2008
I often find I need to use QuickCheck & SmallCheck with e.g. Word8 but
there don't seem to be standard instances. Would these be worth adding?
If so, what would I need to do? Just send a patch to the maintainers?
Thanks, Dominic.
>
> instance Serial Word8 where
> series d = drawnFrom (map fromIntegral [0..d])
> instance Arbitrary Word8 where
> arbitrary =
> do n <- choose ((fromIntegral (minBound::Word8))::Int,
> (fromIntegral (maxBound::Word8))::Int)
> return (fromIntegral n)
>
> instance Arbitrary Word64 where
> arbitrary =
> do n <- choose ((fromIntegral (minBound::Word64))::Integer,
> (fromIntegral (maxBound::Word64))::Integer)
> return (fromIntegral n)
>
> instance Arbitrary Word128 where
> arbitrary =
> do n <- choose ((fromIntegral (minBound::Word128))::Integer,
> (fromIntegral (maxBound::Word128))::Integer)
> return (fromIntegral n)
>
More information about the Libraries
mailing list