[commit: ghc] master: Refactor validity checking for constraints (45f44e2)

git at git.haskell.org git at git.haskell.org
Thu Jul 5 09:52:30 UTC 2018


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

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

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

commit 45f44e2c9d5db2f25c52abb402f197c20579400f
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Jul 4 15:17:54 2018 +0100

    Refactor validity checking for constraints
    
    There are several changes here.
    
    * TcInteract has gotten too big, so I moved all the class-instance
      matching out of TcInteract into a new module ClsInst. It parallels
      the FamInst module.
    
      The main export of ClsInst is matchGlobalInst.
      This now works in TcM not TcS.
    
    * A big reason to make matchGlobalInst work in TcM is that we can
      then use it from TcValidity.checkSimplifiableClassConstraint.
      That extends checkSimplifiableClassConstraint to work uniformly
      for built-in instances, which means that we now get a warning
      if we have givens (Typeable x, KnownNat n); see Trac #15322.
    
    * This change also made me refactor LookupInstResult, in particular
      by adding the InstanceWhat field.  I also changed the name of the
      type to ClsInstResult.
    
      Then instead of matchGlobalInst reporting a staging error (which is
      inappropriate for the call from TcValidity), we can do so in
      TcInteract.checkInstanceOK.
    
    * In TcValidity, we now check quantified constraints for termination.
      For example, this signature should be rejected:
         f :: (forall a. Eq (m a) => Eq (m a)) => blah
      as discussed in Trac #15316.   The main change here is that
      TcValidity.check_pred_help now uses classifyPredType, and has a
      case for ForAllPred which it didn't before.
    
      This had knock-on refactoring effects in TcValidity.


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

45f44e2c9d5db2f25c52abb402f197c20579400f
 compiler/ghc.cabal.in                              |   1 +
 compiler/typecheck/ClsInst.hs                      | 586 +++++++++++++++++++
 compiler/typecheck/TcInteract.hs                   | 634 ++-------------------
 compiler/typecheck/TcSMonad.hs                     |  54 +-
 compiler/typecheck/TcSimplify.hs                   |   2 +-
 compiler/typecheck/TcValidity.hs                   | 170 ++++--
 .../tests/indexed-types/should_compile/T15322.hs   |  12 +
 .../indexed-types/should_compile/T15322.stderr     |   8 +
 .../tests/indexed-types/should_compile/T15322a.hs  |  12 +
 .../indexed-types/should_compile/T15322a.stderr    |  12 +
 testsuite/tests/indexed-types/should_compile/all.T |   2 +
 .../should_compile/SomethingShowable.stderr        |   4 +-
 testsuite/tests/polykinds/T11466.stderr            |   4 +-
 testsuite/tests/quantified-constraints/T15316.hs   |  21 +
 .../tests/quantified-constraints/T15316.stderr     |   6 +
 testsuite/tests/quantified-constraints/all.T       |   1 +
 testsuite/tests/typecheck/should_compile/T10177.hs |   3 +
 .../tests/typecheck/should_compile/T13526.stderr   |   4 +-
 .../should_compile/TcCustomSolverSuper.hs          |  10 +-
 testsuite/tests/typecheck/should_fail/T8912.stderr |   4 +-
 .../tests/typecheck/should_fail/fd-loop.stderr     |   6 -
 .../tests/typecheck/should_fail/tcfail157.stderr   |   7 -
 .../tests/typecheck/should_fail/tcfail211.stderr   |   4 +-
 23 files changed, 881 insertions(+), 686 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 45f44e2c9d5db2f25c52abb402f197c20579400f


More information about the ghc-commits mailing list