[project @ 2004-04-02 13:16:07 by simonpj]
* Improve error message for overlapping instances
* Improve handling of type-variable-only constraints like (Foo a).
Previously we never looked them up in the instance envt, *except* if
-fallow-undecideable-instances was on, because that allows
instance (...) => Foo a
But -fallow-undecideable-instances might be on in the module with the
instance decl, but off in the importing module. Also it's really a per-class
thing. So now we just record in the instance env whether there are any such
strange instances, a kind of short-cut for the lookup.
* Arrange that we are a bit more eager about resolving overloading in
the case of existential pattern matching [George Russel suggestion]
Here's the example (see comments in InstEnv)
-- The key_tys can contain skolem constants, and we can guarantee that those
-- are never going to be instantiated to anything, so we should not involve
-- them in the unification test. Example:
-- class Foo a where { op :: a -> Int }
-- instance Foo a => Foo [a] -- NB overlap
-- instance Foo [Int] -- NB overlap
-- data T = forall a. Foo a => MkT a
-- f :: T -> Int
-- f (MkT x) = op [x,x]
-- The op [x,x] means we need (Foo [a]). Without the filterVarSet we'd
-- complain, saying that the choice of instance depended on the instantiation
-- of 'a'; but of course it isn't *going* to be instantiated.