Skip to content

Expose kind information for type variables with reify

The comment on TyVarI notes that the attached Type is always VarT theName, and that this could potentially be extended. Currently, there isn't a way to access kind information for a type variable through the Template Haskell API. It would be useful (at least for me) to have this ability here.

The limitation on the returned Type comes from the ATyVar clause of reifyThing, which zonks the TyVar to a GHC type and then uses reifyType to convert it to a TH type. For a TyVarTy, reifyType always returns VarT theName.

I can see a few possible ways of exposing kind information here:

(a) Fill the Type argument to TyVarI with SigT (VarT theName) theKind. This could be done either as a special case in place of the call to reifyType in reifyThing, or as a modification to reifyType's behavior. The question of when SigT should be included is open: all the time? when the kind isn't *? when the kind is something that involves more than * and ->?

(b) Change TyVarI from TyVarI Name Type to TyVarI Name TyVarBndr. This seems like the most straightforward, stable way of exposing kind information, but it requires a breaking API change.

Trac metadata
Trac field Value
Version 7.10.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information