simonpj 2003/02/26 09:04:17 PST
Modified files:
ghc/compiler/typecheck Inst.lhs TcBinds.lhs TcClassDcl.lhs
TcExpr.lhs TcHsSyn.lhs
TcMatches.hi-boot TcMatches.hi-boot-5
TcMatches.hi-boot-6 TcMatches.lhs
TcPat.lhs TcUnify.lhs
Log:
----------------------------------
Improve higher-rank type inference
----------------------------------
Yanling Wang pointed out that if we have
f = \ (x :: forall a. a->a). x
it would be reasonable to expect that type inference would get the "right"
rank-2 type for f. She also found that the plausible definition
f :: (forall a. a->a) = \x -> x
acutally failed to type check.
This commit fixes up TcBinds.tcMonoBinds so that it does a better job.
The main idea is that there are three cases to consider in a function binding:
a) 'f' has a separate type signature
In this case, we know f's type everywhere
b) The binding is recursive, and there is no type sig
In this case we must give f a monotype in its RHS
c) The binding is non-recursive, and there is no type sig
Then we do not need to add 'f' to the envt, and can
simply infer a type for the RHS, which may be higher
ranked.
Revision Changes Path
1.114 +4 -3 fptools/ghc/compiler/typecheck/Inst.lhs
1.115 +82 -82 fptools/ghc/compiler/typecheck/TcBinds.lhs
1.131 +1 -1 fptools/ghc/compiler/typecheck/TcClassDcl.lhs
1.149 +9 -17 fptools/ghc/compiler/typecheck/TcExpr.lhs
1.89 +46 -6 fptools/ghc/compiler/typecheck/TcHsSyn.lhs
1.7 +1 -2 fptools/ghc/compiler/typecheck/TcMatches.hi-boot
1.7 +1 -2 fptools/ghc/compiler/typecheck/TcMatches.hi-boot-5
1.4 +1 -3 fptools/ghc/compiler/typecheck/TcMatches.hi-boot-6
1.74 +46 -25 fptools/ghc/compiler/typecheck/TcMatches.lhs
1.87 +4 -4 fptools/ghc/compiler/typecheck/TcPat.lhs
1.44 +4 -41 fptools/ghc/compiler/typecheck/TcUnify.lhs
_______________________________________________
Cvs-ghc mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/cvs-ghc