[GHC] #10561: "deriving (Functor)" on a polykinded type produces ill-kinded instance

GHC ghc-devs at haskell.org
Mon Apr 11 01:16:17 UTC 2016


#10561: "deriving (Functor)" on a polykinded type produces ill-kinded instance
-------------------------------------+-------------------------------------
        Reporter:  rwbarton          |                Owner:
            Type:  bug               |               Status:  closed
        Priority:  normal            |            Milestone:  8.0.1
       Component:  Compiler          |              Version:  7.11
      Resolution:  fixed             |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
                                     |  deriving/should_compile/T10561
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
-------------------------------------+-------------------------------------

Comment (by Ben Gamari <ben@…>):

 In [changeset:"aadde2b90817c577336da0d4a10ea47551d60c7e/ghc" aadde2b/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="aadde2b90817c577336da0d4a10ea47551d60c7e"
 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
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10561#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list