[project @ 2003-02-26 17:04:11 by simonpj]
authorsimonpj <unknown>
Wed, 26 Feb 2003 17:04:16 +0000 (17:04 +0000)
committersimonpj <unknown>
Wed, 26 Feb 2003 17:04:16 +0000 (17:04 +0000)
commitc86e9006fbdc9cb229080dd6a64ce462e9e460af
tree4bf4d80b41b6202e64e47128a795c329051c5339
parentc68c1f2ed802c5cf6e2c23b9f57530df6e2091ee
[project @ 2003-02-26 17:04:11 by simonpj]
----------------------------------
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.
ghc/compiler/typecheck/Inst.lhs
ghc/compiler/typecheck/TcBinds.lhs
ghc/compiler/typecheck/TcClassDcl.lhs
ghc/compiler/typecheck/TcExpr.lhs
ghc/compiler/typecheck/TcHsSyn.lhs
ghc/compiler/typecheck/TcMatches.hi-boot
ghc/compiler/typecheck/TcMatches.hi-boot-5
ghc/compiler/typecheck/TcMatches.hi-boot-6
ghc/compiler/typecheck/TcMatches.lhs
ghc/compiler/typecheck/TcPat.lhs
ghc/compiler/typecheck/TcUnify.lhs