A (very niche) footgun in GHC.Generics

13 Likes

Nice post! There is a great warning flag introduced in GHC 9.8 that I always enable in my projects that have PolyKinds enabled globally (e.g. because it is implied by GHC2021 ) after running into similar problems in the past: -Wmissing-poly-kind-signatures:

It is useful to catch accidentally polykinded types, or to make that polymorphism explicit, without requiring a kind signature for every type.

This could have warned you about ConstructorNamesG being (overly) polymorphic:

warning: [GHC-38417] [-Wmissing-poly-kind-signatures]
    Top-level type constructor with no standalone kind signature:
      type ConstructorNamesG :: forall {k}. k -> Constraint
  |
7 | class ConstructorNamesG f where
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
7 Likes

Wow, wasn’t that the fastest intro to Generics :joy:

Good post.

1 Like

About why K1 R stands for recursion (even when there is no recursion): For example data Self = Ctor Self deriving Generic gives you K1 R Self.

It’s not just GHC.Generics’s footgun, my feet have a good amount of holes in them due to it.

1 Like