[commit: ghc] master: Deriving Functor-like classes should unify kind variables (aadde2b)

git at git.haskell.org git at git.haskell.org
Mon Apr 11 01:16:30 UTC 2016


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

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

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

commit aadde2b90817c577336da0d4a10ea47551d60c7e
Author: RyanGlScott <ryan.gl.scott at gmail.com>
Date:   Mon Apr 11 02:53:23 2016 +0200

    Deriving Functor-like classes should unify kind variables
    
    While the deriving machinery always unifies the kind of the typeclass
    argument with the kind of the datatype, this proves not to be sufficient
    to produce well kinded instances for some poly-kinded datatypes. For
    example:
    
    ```
    newtype Compose (f :: k2 -> *) (g :: k1 -> k2) (a :: k1)
      = Compose (f (g a)) deriving Functor
    ```
    
    would fail because only `k1` would get unified with `*`, causing the
    following
    ill kinded instance to be generated:
    
    ```
    instance (Functor (f :: k2 -> *), Functor (g :: * -> k2)) =>
      Functor (Compose f g) where ...
    ```
    
    To prevent this, we need to take the subtypes and unify their kinds with
    `* -> *`.
    
    Fixes #10524 for good.
    
    Test Plan: ./validate
    
    Reviewers: simonpj, hvr, austin, bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2097
    
    GHC Trac Issues: #10524, #10561


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

aadde2b90817c577336da0d4a10ea47551d60c7e
 compiler/typecheck/TcDeriv.hs                      | 156 +++++++++++++++------
 libraries/base/Data/Functor/Compose.hs             |   7 +-
 testsuite/tests/deriving/should_compile/T10561.hs  |  14 --
 .../tests/deriving/should_compile/T10561.stderr    |   7 -
 testsuite/tests/deriving/should_compile/all.T      |   2 +-
 5 files changed, 117 insertions(+), 69 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 aadde2b90817c577336da0d4a10ea47551d60c7e


More information about the ghc-commits mailing list