ambiguous type variables in existential classes
Simon Peyton-Jones
simonpj@microsoft.com
Wed, 28 Aug 2002 12:20:32 +0100
Hal
I don't quite understand the intuitions behind your program, but the
bug is easy enough:
| instance (Eq e, Foo p) =3D> Foo (Wrap p) where
| foo (Bar p) e q =3D foo p e q
This instance declaration is guaranteed to give problems if it is
ever used, and GHC should probably bleat about it. Suppose=20
you have the constraint=20
Foo (Wrap T)
where T is some type. Using the instance declaration we can simplify
this to the constraints
Eq e
Foo T
where e is a fresh type variable. But we are never going to learn any
thing more about 'e', and so it is correctly reported as ambiguous.
It's
like writing
reverse :: Eq x =3D> [a] -> [a]
Any call to this 'reverse' will give a constraint (Eq x) that is
ambiguous.
Really, GHC should reject the instance declaration.
Simon