[Haskell-cafe] ghc overlapping instances

Isaac Dupree isaacdupree at charter.net
Tue Dec 4 10:41:58 EST 2007


Steffen Mazanek wrote:
> Hello,
> 
> I want to quickcheck a property on a datatype representing
> programs (=[Stmt]) and need to define a specific instance
> 
> instance Arbitrary [Stmt]
> 
> (mainly to restrict the size of the list).

you don't always need to use instances. for example, I have (where 
Predicate is a type I defined which I gave a separate normal Arbitrary 
instance)

arbpredicate :: Gen Predicate
arbpredicate = do ...

prop_assocUnify :: Property
prop_assocUnify =
  forAll arbpredicate $ \a ->
  forAll arbpredicate $ \b ->
  forAll arbpredicate $ \c -> ...boolean result


Isaac


More information about the Haskell-Cafe mailing list