
#10541: Expose kind information for type variables with reify -------------------------------------+------------------------------------- Reporter: spinda | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.10.1 Component: Template | Operating System: Unknown/Multiple Haskell | Type of failure: None/Unknown Keywords: | Blocked By: Architecture: | Related Tickets: Unknown/Multiple | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- The comment on [https://hackage.haskell.org/package/template- haskell-2.10.0.0/docs/Language-Haskell-TH-Syntax.html#v:TyVarI 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 [https://github.com/ghc/ghc/blob/master/compiler/typecheck/TcSplice.hs#L1060 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, [https://github.com/ghc/ghc/blob/master/compiler/typecheck/TcSplice.hs#L1281 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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10541 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler