Add left-to-right impredicative instantiation
authorsimonpj@microsoft.com <unknown>
Wed, 13 Dec 2006 16:29:15 +0000 (16:29 +0000)
committersimonpj@microsoft.com <unknown>
Wed, 13 Dec 2006 16:29:15 +0000 (16:29 +0000)
commita2fcf3aa210edff15c5f4603ac267171f89366f0
tree1e33d19646eee7383fa95894937092234f22b3b7
parente119cde9caf1f2acbde7ff53feebdc27d6c35f8d
Add left-to-right impredicative instantiation

People keep complaining, with some justification, that

runST $ foo

doesn't work.  So I've finally caved in.  The difficulty with the above
is that we need to decide how to instantiate ($)'s type arguments based
on the first argument (runST), and then use that info to check the second
argumnent.  There is a left-to-right flow of information.

It's not hard to implement this, and it's clearly useful.  The main
change is in TcExpr.tcArgs, with some knock-on effects elsewhere.

I was finally provoked into this by Trac #981, which turned out, after some
head-scratching, to be another instance of the same problem.

(There was some bug-fixing too; a type like ((?x::Int) => ...) is a polytype
even though it has no leading for-alls, but the new TcUnify code was not
treating it right.)

Test for this is tc222
compiler/typecheck/TcExpr.lhs
compiler/typecheck/TcMType.lhs
compiler/typecheck/TcUnify.lhs