Ticket #5454 (closed feature request: wontfix)
reify seems to needlessly remove kind ascriptions from type synonym RHSs
Description
I haven't managed to pin down where it happens in the GHC source, but it seems that using TH.reify to query a type synonym's declaration strips out kind ascriptions.
This smells a bit like LiberalTypeSynonyms .
{-# LANGUAGE TemplateHaskell, KindSignatures #-}
module Test where
import Language.Haskell.TH
type T x = ((,,) :: * -> * -> * -> *) x x
reify ''T >>= \x -> runIO (print x) >> return []
emits
TyConI (TySynD Test.T [PlainTV x_1628626975] (AppT (AppT (TupleT 2) (VarT x_1628626975)) (VarT x_1628626975)))
upon :loading in ghci 7.0.3.
My motivation for retaining those kind ascriptions is ticket:5452. I've written a TH workaround in order to avoid patching GHC. Adjusting TupleTs in the head of the unconstrained RHS of a type synonym is understandably impossible, but even if I include kind ascriptions in that type synonym, the kind inference fails. I tinkered and finally noticed that the Info returned by TH.reify ''T simply omits the SigT.
Is this an intended behavior? It seems like the TH user could easily strip out the SigTs if they so wished, and otherwise might want to see them (as I do). A show-stopper scenario for this feature request, I imagine, is that GHC sheds these ascriptions earlier in its pipeline for some terrifyingly clever reason.
