[Haskell-cafe] Quickcheck examples and Data.Word32

Joel Reymont joelr1 at gmail.com
Thu Oct 27 19:13:07 EDT 2005

Just one more question...

data Prop = forall a b. (Eq a, Eq b, Show a, Packet b, Convertible a b)
     => Attr a b := a
        deriving (Typeable)

data Attr a b = Attr String
     (a -> Dynamic, Dynamic -> Maybe a)
     (a -> b, b -> a)

makeAttr :: (Typeable a, Convertible a b) => String -> Attr a b
makeAttr name = Attr name
                 (toDyn, fromDynamic)
                 (convert_AB, convert_BA)

I can do this for Attr

instance (Typeable a, Arbitrary a, Typeable b, Arbitrary b,  
Convertible a b) => Arbitrary (Attr a b) where
     arbitrary = makeAttr `fmap` arbitrary
     coarbitrary a = error "Not implemented"

How do I define an arbitrary prop, though? Following does not work:

arbitraryProp :: forall a b.(Arbitrary a, Arbitrary b) => Attr a b ->  
Gen Prop
arbitraryProp  = arbitrary := arbitrary

     Thanks, Joel


More information about the Haskell-Cafe mailing list