[commit: ghc] master: Rewrite `Coercible` solver (0cc47eb)

git at git.haskell.org git at git.haskell.org
Fri Dec 12 22:56:14 UTC 2014


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

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

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

commit 0cc47eb90805f3e166ac4d3991e66d3346ca05e7
Author: Richard Eisenberg <eir at cis.upenn.edu>
Date:   Fri Dec 12 17:19:21 2014 -0500

    Rewrite `Coercible` solver
    
    Summary:
    This is a rewrite of the algorithm to solve for Coercible "instances".
    
    A preliminary form of these ideas is at
    https://ghc.haskell.org/trac/ghc/wiki/Design/NewCoercibleSolver
    
    The basic idea here is that the `EqPred` constructor of `PredTree`
    now is parameterised by a new type `EqRel` (where
    `data EqRel = NomEq | ReprEq`). Thus, every equality constraint can
    now talk about nominal equality (the usual case) or representational
    equality (the `Coercible` case).
    
    This is a change from the previous
    behavior where `Coercible` was just considered a regular class with
    a special case in `matchClassInst`.
    
    Because of this change, representational equalities are now
    canonicalized just like nominal ones, allowing more equalities
    to be solved -- in particular, the case at the top of #9117.
    
    A knock-on effect is that the flattener must be aware of the
    choice of equality relation, because the inert set now stores
    both representational inert equalities alongside the nominal
    inert equalities. Of course, we can use representational equalities
    to rewrite only within another representational equality --
    thus the parameterization of the flattener.
    
    A nice side effect of this change is that I've introduced a new
    type `CtFlavour`, which tracks G vs. W vs. D, removing some ugliness
    in the flattener.
    
    This commit includes some refactoring as discussed on D546.
    It also removes the ability of Deriveds to rewrite Deriveds.
    
    This fixes bugs #9117 and #8984.
    
    Reviewers: simonpj, austin, nomeata
    
    Subscribers: carter, thomie
    
    Differential Revision: https://phabricator.haskell.org/D546
    
    GHC Trac Issues: #9117, #8984


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

0cc47eb90805f3e166ac4d3991e66d3346ca05e7
 compiler/basicTypes/DataCon.hs                     |   6 +-
 compiler/deSugar/DsBinds.hs                        |   5 +-
 compiler/typecheck/FamInst.hs                      |  93 ++-
 compiler/typecheck/FunDeps.hs                      |   6 +-
 compiler/typecheck/Inst.hs                         |  15 +-
 compiler/typecheck/TcCanonical.hs                  | 691 +++++++++++++++------
 compiler/typecheck/TcDeriv.hs                      |   1 -
 compiler/typecheck/TcErrors.hs                     | 209 ++++---
 compiler/typecheck/TcEvidence.hs                   | 161 ++++-
 compiler/typecheck/TcFlatten.hs                    | 358 +++++++----
 compiler/typecheck/TcHsSyn.hs                      |  32 +-
 compiler/typecheck/TcInteract.hs                   | 343 +++-------
 compiler/typecheck/TcMType.hs                      |   6 +-
 compiler/typecheck/TcRnTypes.hs                    |  68 +-
 compiler/typecheck/TcSMonad.hs                     | 163 +++--
 compiler/typecheck/TcSimplify.hs                   |  19 +-
 compiler/typecheck/TcType.hs                       |  34 +-
 compiler/typecheck/TcValidity.hs                   |  61 +-
 compiler/types/Coercion.hs                         | 125 ++--
 compiler/types/FamInstEnv.hs                       |  71 +--
 compiler/types/Type.hs                             |  62 +-
 compiler/utils/MonadUtils.hs                       |  14 +-
 compiler/utils/Util.hs                             |  11 +
 testsuite/tests/deriving/should_fail/T1496.stderr  |  14 +-
 testsuite/tests/deriving/should_fail/T4846.stderr  |   9 +-
 testsuite/tests/deriving/should_fail/T5498.stderr  |  16 +-
 testsuite/tests/deriving/should_fail/T6147.stderr  |  12 +-
 testsuite/tests/deriving/should_fail/T7148.stderr  |  32 +-
 testsuite/tests/deriving/should_fail/T7148a.stderr |  19 +-
 testsuite/tests/deriving/should_fail/T8851.stderr  |  22 +-
 testsuite/tests/deriving/should_fail/T8984.hs      |   8 +
 testsuite/tests/deriving/should_fail/T8984.stderr  |  11 +
 testsuite/tests/deriving/should_fail/all.T         |   1 +
 testsuite/tests/gadt/CasePrune.stderr              |  12 +-
 testsuite/tests/ghci/scripts/GhciKinds.hs          |   4 +
 testsuite/tests/ghci/scripts/GhciKinds.script      |   5 +
 testsuite/tests/ghci/scripts/GhciKinds.stdout      |   6 +
 testsuite/tests/ghci/scripts/ghci051.stderr        |   2 +-
 .../tests/indexed-types/should_fail/T9580.stderr   |   7 +-
 testsuite/tests/roles/should_fail/Roles10.stderr   |  11 +-
 .../tests/roles/should_fail/RolesIArray.stderr     | 151 +++--
 .../tests/typecheck/should_compile/T9117_3.hs      |   7 +
 testsuite/tests/typecheck/should_compile/T9708.hs  |   9 +-
 testsuite/tests/typecheck/should_compile/all.T     |   5 +-
 .../tests/typecheck/should_fail/TcCoercibleFail.hs |   6 +-
 .../typecheck/should_fail/TcCoercibleFail.stderr   |  65 +-
 .../typecheck/should_fail/TcCoercibleFail3.stderr  |  11 +-
 .../tests/typecheck/should_run/TcCoercible.hs      |  15 +-
 48 files changed, 1861 insertions(+), 1153 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 0cc47eb90805f3e166ac4d3991e66d3346ca05e7


More information about the ghc-commits mailing list