Skip to content

Enable PolyKinds in GHC.Generics

As suggested in this Haskell libraries mailing list thread. Among other benefits, this would allow use of generic functions with Proxy t when t is of a kind other than *.

There seem to be more changes required than just putting {-# LANGUAGE PolyKinds #-} in GHC.Generics, however, since I tried doing that myself and found myself unable to properly derive Generic(1) instances in GHC.Generics. Here is a snippet of the resulting error message:

libraries/base/GHC/Generics.hs:826:1: error:
    Couldn't match type ‘M1 i0 c0 (M1 i1 c1 U1) p0’ with ‘M1 D x’
    Expected type: Rep (Proxy t) x
      Actual type: M1 i0 c0 (M1 i1 c1 U1) p0
    Relevant bindings include
      from :: Proxy t -> Rep (Proxy t) x
        (bound at libraries/base/GHC/Generics.hs:826:1)
    In the expression: M1 (M1 U1)
    In an equation for ‘from’: from Proxy = M1 (M1 U1)
    When typechecking the code for ‘from’
      in a derived instance for ‘Generic (Proxy t)’:
      To see the code I am typechecking, use -ddump-deriv

libraries/base/GHC/Generics.hs:826:1: error:
    Couldn't match type ‘M1 t0 t1 (M1 t3 t4 U1) t2’ with ‘M1 D x’
    Expected type: Rep (Proxy t) x
      Actual type: M1 t0 t1 (M1 t3 t4 U1) t2
    Relevant bindings include
      to :: Rep (Proxy t) x -> Proxy t
        (bound at libraries/base/GHC/Generics.hs:826:1)
    In the pattern: M1 (M1 U1)
    In an equation for ‘to’: to (M1 (M1 U1)) = Proxy
    When typechecking the code for ‘to’
      in a derived instance for ‘Generic (Proxy t)’:
      To see the code I am typechecking, use -ddump-deriv
    In the instance declaration for ‘Generic (Proxy t)’
Trac metadata
Trac field Value
Version 7.10.2
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC dreixel
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information