[GHC] #10775: Enable PolyKinds in GHC.Generics

GHC ghc-devs at haskell.org
Sun Aug 16 14:12:32 UTC 2015


#10775: Enable PolyKinds in GHC.Generics
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  libraries/base    |                 Version:  7.10.2
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 > To make `Generic1 :: k -> *` instead of its current `Generic1 :: * -> *`
 kind?

 No, my main motivation involves `Proxy` from `Data.Proxy`. Currently,
 `Proxy` is defined like so:

 {{{#!hs
 data Proxy (t :: k) = Proxy
 }}}

 using `PolyKinds`, but `Proxy` has a `Generic` instance defined in
 `GHC.Generics`, a module which doesn't have `PolyKinds` enabled. As a
 result, the resulting `Generic` instance is

 {{{#!hs
 instance Generic (Proxy (t :: *))
 }}}

 This prevents you from using certain `Proxy` values with generic
 functions:

 {{{
 $ ghci -XPolyKinds
 GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
 λ> import GHC.Generics
 λ> import Data.Proxy
 λ> from (Proxy :: Proxy Int)
 M1 {unM1 = M1 {unM1 = U1}}
 λ> from (Proxy :: Proxy Maybe)

 <interactive>:5:1:
     No instance for (Generic (Proxy Maybe))
       (maybe you haven't applied enough arguments to a function?)
       arising from a use of ‘from’
     In the expression: from (Proxy :: Proxy Maybe)
     In an equation for ‘it’: it = from (Proxy :: Proxy Maybe)
 }}}

 If `GHC.Generics` enabled `PolyKinds`, that would fix this issue. It would
 also make many data types in `GHC.Generics` poly-kinded as well, as an
 added bonus.

 (I had originally thought `Generic1`/`Rep1` could be poly-kinded, but upon
 further thought, I think the current GHC generics mechanism assumes that
 the last type parameter is always of kind `* -> *`.)

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


More information about the ghc-tickets mailing list