Another major improvement of "improvement"
authorSimon Peyton Jones <simonpj@microsoft.com>
Thu, 7 May 2015 08:07:51 +0000 (09:07 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Thu, 11 Jun 2015 12:32:27 +0000 (13:32 +0100)
commitddbb97d00fdbc5870a4076ed15af8e607b161cb2
treeefc9b18c9786fa059e0ff8999a790e24f82ecb60
parentca39b96ee783e124909a89ea3ad366bf99defa7b
Another major improvement of "improvement"

I wasn't very happy with my fix to Trac #10009. This is much better.

The main idea is that the inert set now contains a "model", which
embodies *all* the (nominal) equalities that we know about, with
a view to exposing unifications.  This requires a lot fewer iterations
of the solver than before.

There are extensive comments in
 TcSMonad:  Note [inert_model: the inert model]
            Note [Adding an inert canonical constraint the InertCans]

The big changes are

  * New inert_model field in InertCans

  * Functions addInertEq, addInertCan deal with adding a
    constraint, maintaining the model

  * A nice improvement is that unification variables can
    unify with fmvs, so that from, say   alpha ~ fmv
    we get              alpha := fmv
    See Note [Orientation of equalities with fmvs] in TcFlatten
    It's still not perfect, as the Note explains

New flag -fconstraint-solver-iterations=n, allows us to control
the number of constraint solver iterations, and in particular
will flag up when it's more than a small number.

Performance is generally slightly better:
T5837 is a lot better for some reason.
30 files changed:
compiler/basicTypes/BasicTypes.hs
compiler/main/Constants.hs
compiler/main/DynFlags.hs
compiler/typecheck/TcCanonical.hs
compiler/typecheck/TcFlatten.hs
compiler/typecheck/TcInteract.hs
compiler/typecheck/TcRnTypes.hs
compiler/typecheck/TcSMonad.hs
compiler/typecheck/TcSimplify.hs
compiler/typecheck/TcType.hs
docs/users_guide/flags.xml
testsuite/tests/indexed-types/should_fail/T2544.stderr
testsuite/tests/indexed-types/should_fail/T2627b.stderr
testsuite/tests/indexed-types/should_fail/T3330c.stderr
testsuite/tests/indexed-types/should_fail/T4254.stderr
testsuite/tests/indexed-types/should_fail/T6123.stderr
testsuite/tests/indexed-types/should_fail/T9662.stderr
testsuite/tests/perf/compiler/all.T
testsuite/tests/typecheck/should_compile/Improvement.hs
testsuite/tests/typecheck/should_compile/T10009.hs
testsuite/tests/typecheck/should_compile/tc237.hs
testsuite/tests/typecheck/should_fail/IPFail.stderr
testsuite/tests/typecheck/should_fail/T5236.hs
testsuite/tests/typecheck/should_fail/T5853.stderr
testsuite/tests/typecheck/should_fail/T5978.hs
testsuite/tests/typecheck/should_fail/T5978.stderr
testsuite/tests/typecheck/should_fail/TcCoercibleFail.stderr
testsuite/tests/typecheck/should_fail/tcfail138.hs
testsuite/tests/typecheck/should_fail/tcfail143.stderr
testsuite/tests/typecheck/should_fail/tcfail201.stderr