RE: ambiguous type variables in existential classes
Hal I don't quite understand the intuitions behind your program, but the bug is easy enough: | instance (Eq e, Foo p) => Foo (Wrap p) where | foo (Bar p) e q = 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 you have the constraint 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 => [a] -> [a] Any call to this 'reverse' will give a constraint (Eq x) that is ambiguous. Really, GHC should reject the instance declaration. Simon
participants (1)
-
Simon Peyton-Jones