[project @ 2002-03-08 15:50:53 by simonpj]
authorsimonpj <unknown>
Fri, 8 Mar 2002 15:50:57 +0000 (15:50 +0000)
committersimonpj <unknown>
Fri, 8 Mar 2002 15:50:57 +0000 (15:50 +0000)
commita170160cc21678c30ca90696d4ae0fc1155f25bf
treedde40bac2e53265c962ddfd076ef506f28a9093d
parent4593b1053cdc55c10f3df804630a1d90890d8473
[project @ 2002-03-08 15:50:53 by simonpj]
--------------------------------------
Lift the class-method type restriction
--------------------------------------

Haskell 98 prohibits class method types to mention constraints on the
class type variable, thus:

  class Seq s a where
    fromList :: [a] -> s a
    elem     :: Eq a => a -> s a -> Bool

The type of 'elem' is illegal in Haskell 98, because it contains the
constraint 'Eq a', which constrains only the class type variable (in
this case 'a').

This commit lifts the restriction.  The way we do that is to do a full
context reduction (tcSimplifyCheck) step for each method separately in
TcClassDcl.tcMethodBind, rather than doing a single context reduction
for the whole group of method bindings.

As a result, I had to reorganise the code a bit, and tidy up.
16 files changed:
ghc/compiler/typecheck/Inst.lhs
ghc/compiler/typecheck/TcBinds.lhs
ghc/compiler/typecheck/TcClassDcl.lhs
ghc/compiler/typecheck/TcEnv.lhs
ghc/compiler/typecheck/TcExpr.lhs
ghc/compiler/typecheck/TcInstDcls.lhs
ghc/compiler/typecheck/TcMType.lhs
ghc/compiler/typecheck/TcMatches.lhs
ghc/compiler/typecheck/TcMonad.lhs
ghc/compiler/typecheck/TcMonoType.lhs
ghc/compiler/typecheck/TcPat.lhs
ghc/compiler/typecheck/TcRules.lhs
ghc/compiler/typecheck/TcSimplify.lhs
ghc/compiler/typecheck/TcTyClsDecls.lhs
ghc/compiler/typecheck/TcType.lhs
ghc/compiler/typecheck/TcUnify.lhs