This is not an error in the compilers!  In this example, it is the
context of the derived Eq operator that is the problem.  In the
expression NilSet == NilSet, the typing of == is

(==) :: Eq a => a -> a -> Bool

This `a' is instantiated by Set b (to choose a different type
variable), not Eq b => Set b, resulting in a typing of

Eq(Set b) => Set b -> Set b -> Bool

for your expression.  Since the instance for Eq derived by the
compiler for Set is:

instance Eq a => Eq (Set a) where ...

context reduction will yield a final type of 

Eq b => Set b -> Set b -> Bool

The ambiguous Eq b comes from the instance for Eq, not the data
constructor NilSet.  This sort of ambiguity problem is not solved by
the restriction in the report in constructor contexts.

Moral:  If all three compilers disagree with you, you must be wrong :-)

   John Peterson
   Yale Haskell Project


Reply via email to