[commit: ghc] master: Implicitly bind kind variables in type family instance RHSes when it's sensible (0829821)

git at git.haskell.org git at git.haskell.org
Tue Sep 5 15:10:20 UTC 2017


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

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

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

commit 0829821a6b886788a3ba6989e57e25a037bb6d05
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Tue Sep 5 11:00:56 2017 -0400

    Implicitly bind kind variables in type family instance RHSes when it's sensible
    
    Summary:
    Before, there was a discrepancy in how GHC renamed type synonyms as
    opposed to type family instances. That is, GHC would accept definitions like
    this one:
    
    ```lang=haskell
    type T = (Nothing :: Maybe a)
    ```
    
    However, it would not accept a very similar type family instance:
    
    ```lang=haskell
    type family   T :: Maybe a
    type instance T = (Nothing :: Maybe a)
    ```
    
    The primary goal of this patch is to bring the renaming of type family
    instances up to par with that of type synonyms, causing the latter definition
    to be accepted, and fixing #14131.
    
    In particular, we now allow kind variables on the right-hand sides of type
    (and data) family instances to be //implicitly// bound by LHS type (or kind)
    patterns (as opposed to type variables, which must always be explicitly
    bound by LHS type patterns only). As a consequence, this allows programs
    reported in #7938 and #9574 to typecheck, whereas before they would
    have been rejected.
    
    Implementation-wise, there isn't much trickery involved in making this happen.
    We simply need to bind additional kind variables from the RHS of a type family
    in the right place (in particular, see `RnSource.rnFamInstEqn`, which has
    undergone a minor facelift).
    
    While doing this has the upside of fixing #14131, it also made it easier to
    trigger #13985, so I decided to fix that while I was in town. This was
    accomplished by a careful blast of `reportFloatingKvs` in `tcFamTyPats`.
    
    Test Plan: ./validate
    
    Reviewers: simonpj, goldfire, austin, bgamari
    
    Reviewed By: simonpj
    
    Subscribers: rwbarton, thomie
    
    GHC Trac Issues: #13985, #14131
    
    Differential Revision: https://phabricator.haskell.org/D3872


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

0829821a6b886788a3ba6989e57e25a037bb6d05
 compiler/rename/RnSource.hs                        |  81 ++++---
 compiler/rename/RnTypes.hs                         |  15 +-
 compiler/typecheck/TcHsType.hs                     |  42 ++++
 compiler/typecheck/TcTyClsDecls.hs                 |  30 ++-
 docs/users_guide/8.4.1-notes.rst                   |  18 ++
 docs/users_guide/glasgow_exts.rst                  |  72 +++++-
 .../tests/indexed-types/should_compile/T14131.hs   |  29 +++
 testsuite/tests/indexed-types/should_compile/all.T |   1 +
 .../tests/indexed-types/should_fail/T5515.stderr   |   8 +-
 .../tests/indexed-types/should_fail/T7938.stderr   |   8 +-
 .../tests/parser/should_compile/DumpRenamedAst.hs  |   9 +-
 .../parser/should_compile/DumpRenamedAst.stderr    | 263 +++++++++++++++++----
 testsuite/tests/polykinds/T13985.hs                |  27 +++
 testsuite/tests/polykinds/T13985.stderr            |  39 +++
 testsuite/tests/polykinds/T9574.stderr             |   4 -
 testsuite/tests/polykinds/all.T                    |   3 +-
 16 files changed, 542 insertions(+), 107 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 0829821a6b886788a3ba6989e57e25a037bb6d05


More information about the ghc-commits mailing list