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.