Is there a way to squeeze this boilerplate code?

class Arbitrary
instance Arbitrary Word16 where
    arbitrary = do let mx,mn :: Integer
                       mx = fromIntegral (maxBound :: Word16)
                       mn = fromIntegral (minBound :: Word16)
                   c <- choose (mx, mn)
                   return (fromIntegral c)
    coarbitrary a = error "Not implemented"

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)
    coarbitrary a = error "Not implemented"

instance Arbitrary Word64 where
    arbitrary = do let mx,mn :: Integer
                       mx = fromIntegral (maxBound :: Word64)
                       mn = fromIntegral (minBound :: Word64)
                   c <- choose (mx, mn)
                   return (fromIntegral c)
    coarbitrary a = error "Not implemented"


On Oct 27, 2005, at 5:35 PM, Sebastian Sylvan wrote:

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)


--
http://wagerlabs.com/





_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to