[Haskell-cafe] Quickcheck examples and Data.Word32
Sebastian Sylvan
sebastian.sylvan at gmail.com
Thu Oct 27 12:35:38 EDT 2005
On 10/27/05, Sebastian Sylvan <sebastian.sylvan at gmail.com> wrote:
> On 10/27/05, Joel Reymont <joelr1 at gmail.com> wrote:
> > Would it cover the range between minBound :: Word32 and maxBound ::
> > Word32? I cannot figure out how to do this since maxBound :: Int32 is
> > less that that of Word32.
> >
> > Also, I get the following error with ghci -fglasgow-exts
> >
> > foo.hs:7:52: parse error on input `.'
>
> Okay, try this then:
>
> import Data.Word
> import Test.QuickCheck
>
> instance Arbitrary Word32 where
> arbitrary = do let mx,mn :: Integer
> mx = fromIntegral (maxBound :: Word32)
> mn = fromIntegral (minBound :: Word32)
> c <- choose (mx, mn)
> return (fromIntegral c)
>
Sorry, indentation got screwed up there...
instance Arbitrary Word32 where
arbitrary = do let mx,mn :: Integer
mx = fromIntegral (maxBound :: Word32)
mn = fromIntegral (minBound :: Word32)
c <- choose (mx, mn)
return (fromIntegral c)
More information about the Haskell-Cafe
mailing list