[commit: ghc] master: Stop inferring over-polymorphic kinds (1f5cc9d)

git at git.haskell.org git at git.haskell.org
Sun Mar 10 14:31:29 UTC 2019


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

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

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

commit 1f5cc9dc8aeeafa439d6d12c3c4565ada524b926
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Thu Feb 21 15:27:17 2019 +0000

    Stop inferring over-polymorphic kinds
    
    Before this patch GHC was trying to be too clever
    (Trac #16344); it succeeded in kind-checking this
    polymorphic-recursive declaration
    
        data T ka (a::ka) b
          = MkT (T Type           Int   Bool)
                (T (Type -> Type) Maybe Bool)
    
    As Note [No polymorphic recursion] discusses, the "solution" was
    horribly fragile.  So this patch deletes the key lines in
    TcHsType, and a wodge of supporting stuff in the renamer.
    
    There were two regressions, both the same: a closed type family
    decl like this (T12785b) does not have a CUSK:
      type family Payload (n :: Peano) (s :: HTree n x) where
        Payload Z (Point a) = a
        Payload (S n) (a `Branch` stru) = a
    
    To kind-check the equations we need a dependent kind for
    Payload, and we don't get that any more.  Solution: make it
    a CUSK by giving the result kind -- probably a good thing anyway.
    
    The other case (T12442) was very similar: a close type family
    declaration without a CUSK.


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

1f5cc9dc8aeeafa439d6d12c3c4565ada524b926
 compiler/deSugar/DsMeta.hs                         |  15 +--
 compiler/hieFile/HieAst.hs                         |   2 +-
 compiler/hsSyn/HsTypes.hs                          |  32 +++---
 compiler/rename/RnSource.hs                        |   4 +-
 compiler/rename/RnTypes.hs                         |  14 +--
 compiler/typecheck/TcHsType.hs                     | 116 ++++++++++-----------
 compiler/typecheck/TcTyClsDecls.hs                 |   6 +-
 testsuite/tests/dependent/should_compile/T12442.hs |   3 +-
 .../dependent/should_compile/T16326_Compile1.hs    |   4 +-
 .../tests/dependent/should_compile/T16344b.hs      |  10 ++
 testsuite/tests/dependent/should_compile/all.T     |   2 +
 testsuite/tests/dependent/should_fail/T16344.hs    |   8 ++
 .../tests/dependent/should_fail/T16344.stderr      |   6 ++
 testsuite/tests/dependent/should_fail/T16344a.hs   |  11 ++
 .../tests/dependent/should_fail/T16344a.stderr     |   6 ++
 testsuite/tests/dependent/should_fail/all.T        |   2 +
 .../parser/should_compile/DumpRenamedAst.stderr    |  32 ++----
 .../tests/parser/should_compile/T14189.stderr      |  15 ++-
 testsuite/tests/typecheck/should_fail/T12785b.hs   |   4 +-
 utils/haddock                                      |   2 +-
 20 files changed, 146 insertions(+), 148 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 1f5cc9dc8aeeafa439d6d12c3c4565ada524b926


More information about the ghc-commits mailing list