Make 'improvement' work properly in TcSimplify
authorsimonpj@microsoft.com <unknown>
Sat, 27 Oct 2007 15:54:59 +0000 (15:54 +0000)
committersimonpj@microsoft.com <unknown>
Sat, 27 Oct 2007 15:54:59 +0000 (15:54 +0000)
commit6ac37f3bfd72d6fdc819821bfaea1aa70d46f53c
tree98b0364a7021ffd7e889bb319c13364461e086b4
parent0c11d889934ea6e5311f38f5d142aff9e22abb7f
Make 'improvement' work properly in TcSimplify

(Please merge this, and the preceding
handful from me to the 6.8 branch.)

This patch fixes a serious problem in the type checker, whereby
TcSimplify was going into a loop because it thought improvement
had taken place, but actually the unificataion was actually deferred.

We thereby fix Trac #1781, #1783, #1795, and #1797!

In fixing this I found what a mess TcSimplify.reduceContext is!
We need to fix this.

The main idea is to replace the "improvement flag" in Avails with
a simpler and more direct test: have any of the mutable type variables
in the (zonked) 'given' or 'irred' constraints been filled in?
This test uses the new function TcMType.isFilledMetaTyVar; the test
itself is towards the end of reduceContext.

I fixed a variety of other infelicities too, and left some ToDos.
compiler/typecheck/TcMType.lhs
compiler/typecheck/TcSimplify.lhs