[project @ 2004-04-02 13:16:07 by simonpj]
authorsimonpj <unknown>
Fri, 2 Apr 2004 13:16:09 +0000 (13:16 +0000)
committersimonpj <unknown>
Fri, 2 Apr 2004 13:16:09 +0000 (13:16 +0000)
commit2a0ee8e52378ff3d9b90afdeae24df376e299a1c
tree95bd6b7ba5913c61c345ea0cea2592e46c7b5003
parent68021ad91cae77f6a16202b2c2431bbd834f8e3a
[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.
ghc/compiler/typecheck/Inst.lhs
ghc/compiler/typecheck/TcSimplify.lhs
ghc/compiler/types/InstEnv.lhs