Skip to content

Decide about naming of variables in TyCons

Consider

type T :: forall (x :: Type). x -> Type   -- Standalone kind signature
data T (a :: k) = MkT (a :: k)            -- Declaration

Now suppose, in GHCi, you say :kind T.

  • What kind would you expect to see?
    • T :: forall x. x -> Type, taking the name of the kind variable from the kind signature.
    • T :: forall k. k -> Type, taking the name of the kind variable from the header of the declaration.
  • Does it matter anyway?

The names used in the kind signature are fully alpha-renamable. The names used in the header of the declaration are not so renamable, because they scope over the body of the declaration, in this case the data constructors. (In a class declaration the type variables in the header scope over the method signatures and associated types.)

In HEAD we took the names from the kind signature, and used a variety of extra plumbing to make the declaration variables scope correctly. In !7105 (closed) I changed this to use the variable names from the declaration header, because the ones from the signature are fully alpha-renamable.

If we wanted to revert to the previous behaviour, we could do so by making the tyConKind field of a TyCon hold the kind from the signature, perhaps with different naming than the [TyConBinder] for the TyCon. (Currently the tyConKind field is just a cache for mkTyConKind tyConBinders tyConResKind.) Not difficult, but a bit of extra plumbing.

This ticket is to describe the issue and ask what choice we should make.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information