[commit: ghc] master: Improve improvement in the constraint solver (a1275a7)

git at git.haskell.org git at git.haskell.org
Wed Apr 29 14:05:22 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/a1275a762ec04c1159ae37199b1c8f998a5c5499/ghc

>---------------------------------------------------------------

commit a1275a762ec04c1159ae37199b1c8f998a5c5499
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Apr 29 13:43:09 2015 +0100

    Improve improvement in the constraint solver
    
    This regrettably-big patch substantially improves the way in which
    "improvement" happens in the constraint solver.  It was triggered by
    trying to crack Trac #10009, but it turned out to solve #10340 as
    well.
    
    The big picture, with several of the trickiest examples, is described
    in Note [The improvement story] in TcInteract.
    
    The major change is this:
    
    * After solving we explicitly try "improvement", by
         - making the unsolved Wanteds into Deriveds
         - allowing Deriveds to rewrite Deriveds
      This more aggressive rewriting "unlocks" some extra
      guess-free unifications.
    
    * The main loop is in TcInteract.solveSimpleWanteds, but I also ended
      up refactoring TcSimplify.simpl_loop, and its surrounding code.
    
      Notably, any insolubles from the Givens are pulled out
      and treated separately, rather than staying in the inert set
      during the solveSimpleWanteds loop.
    
    There are a lot of follow-on changes
    
    * Do not emit generate Derived improvements from Wanteds.
      This saves work in the common case where they aren't needed.
    
    * For improvement we should really do type-class reduction on Derived
      constraints in doTopReactDict.  That entailed changing the GenInst
      constructor a bit; a local and minor change
    
    * Some annoying faffing about with dropping derived constraints;
      see dropDerivedWC, dropDerivedSimples, dropDerivedInsols,
      and their Notes.
    
    * Some substantial refactoring in TcErrors.reportWanteds.
      This work wasn't strictly forced, but I got sucked into it.
      All the changes are in TcErrors.
    
    * Use TcS.unifyTyVar consistently, rather than setWantedTyBind,
      so that unifications are properly tracked.
    
    * Refactoring around solveWantedsTcM, solveWantedsAndDrop.
      They previously guaranteed a zonked result, but it's more
      straightforward for clients to zonk.


>---------------------------------------------------------------

a1275a762ec04c1159ae37199b1c8f998a5c5499
 compiler/typecheck/TcCanonical.hs                  |  36 +-
 compiler/typecheck/TcDeriv.hs                      |   7 +-
 compiler/typecheck/TcErrors.hs                     | 163 +++---
 compiler/typecheck/TcFlatten.hs                    |  87 +--
 compiler/typecheck/TcInteract.hs                   | 610 ++++++++++++++++-----
 compiler/typecheck/TcRnTypes.hs                    |  79 ++-
 compiler/typecheck/TcSMonad.hs                     | 167 +++---
 compiler/typecheck/TcSimplify.hs                   | 234 +++-----
 .../tests/indexed-types/should_compile/T10340.hs   |  17 +
 testsuite/tests/indexed-types/should_compile/all.T |   1 +
 .../indexed-types/should_fail/ExtraTcsUntch.stderr |  16 +-
 .../tests/indexed-types/should_fail/T4093a.hs      |   2 +
 .../tests/indexed-types/should_fail/T4093a.stderr  |  18 +-
 .../tests/indexed-types/should_fail/T4254.stderr   |   4 +
 .../tests/indexed-types/should_fail/T7729.stderr   |   4 +-
 .../tests/indexed-types/should_fail/T9662.stderr   |  72 +--
 testsuite/tests/module/mod71.stderr                |  14 +-
 testsuite/tests/typecheck/should_compile/FD3.hs    |   9 +
 .../tests/typecheck/should_compile/FD3.stderr      |  13 +-
 .../tests/typecheck/should_compile/Improvement.hs  |  17 +
 testsuite/tests/typecheck/should_compile/T10009.hs |  62 +++
 testsuite/tests/typecheck/should_compile/all.T     |   2 +
 .../tests/typecheck/should_fail/FDsFromGivens.hs   |  15 +-
 .../typecheck/should_fail/FDsFromGivens.stderr     |  27 +-
 .../{FDsFromGivens.hs => FDsFromGivens2.hs}        |  12 +-
 ...{FDsFromGivens.stderr => FDsFromGivens2.stderr} |   8 +-
 testsuite/tests/typecheck/should_fail/T1899.stderr |   6 +-
 testsuite/tests/typecheck/should_fail/T5246.stderr |   2 +-
 testsuite/tests/typecheck/should_fail/T5570.stderr |   2 +-
 testsuite/tests/typecheck/should_fail/T5689.stderr |  26 +-
 testsuite/tests/typecheck/should_fail/T5691.hs     |   0
 testsuite/tests/typecheck/should_fail/T5691.stderr |  14 +-
 testsuite/tests/typecheck/should_fail/T5978.stderr |   8 +-
 testsuite/tests/typecheck/should_fail/T7368.stderr |   2 +-
 .../tests/typecheck/should_fail/T7368a.stderr      |   2 +-
 testsuite/tests/typecheck/should_fail/T7453.stderr |  20 +-
 testsuite/tests/typecheck/should_fail/T7696.stderr |   8 +-
 testsuite/tests/typecheck/should_fail/T8142.stderr |  26 +-
 testsuite/tests/typecheck/should_fail/T8262.stderr |   2 +-
 testsuite/tests/typecheck/should_fail/T8603.stderr |  13 +-
 testsuite/tests/typecheck/should_fail/T9612.stderr |   2 +-
 testsuite/tests/typecheck/should_fail/all.T        |   1 +
 testsuite/tests/typecheck/should_fail/mc25.stderr  |   4 +-
 .../tests/typecheck/should_fail/tcfail090.stderr   |   2 +-
 .../tests/typecheck/should_fail/tcfail122.stderr   |   2 +-
 .../tests/typecheck/should_fail/tcfail123.stderr   |   2 +-
 .../tests/typecheck/should_fail/tcfail143.stderr   |   6 +-
 .../tests/typecheck/should_fail/tcfail159.stderr   |   2 +-
 .../tests/typecheck/should_fail/tcfail200.stderr   |   2 +-
 .../tests/typecheck/should_fail/tcfail201.stderr   |   4 +-
 50 files changed, 1095 insertions(+), 759 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc a1275a762ec04c1159ae37199b1c8f998a5c5499


More information about the ghc-commits mailing list