Refactor Template Haskell syntax conversions
On TemplateHaskell/Conversions there is a proposed refactoring of the Tempate Haskell-related syntax conversions. This task is to do that refactoring.
Edit: link.
Amendment by @sgraf812:
Concretely, we have (the wiki page is for Dec, but Type is nice and concrete)
GHC.Tc.Gen.Splice.reifyType :: Core.Type -> TcM TH.Type-
GHC.HsToCore.Quote.repTy :: HsType GhcRn -> MetaM (Core (M TH.Type))(whereMetaM ~= ReaderT _ TcM) GHC.ThToHs.convertToHsType :: ... -> TH.Type -> Either _ (LHsType GhcPs)
It would be nice to factor
-
reifyType(1) intoreifyType1 :: Core.Type -> TcM (HsType GhcRn)for haddock (SG: I don't know how up-to-date this is) andhsToTh :: HsType GhcRn -> TH.Type -
repTyinto the samehsToTh :: HsType GhcRn -> TH.TypeandrepThTy :: TH.Type -> MetaM (Core (M TH.Type)) - Now the implementation of
repTy1is entirely mechanical and can be derived with TH! It is quite likeLift TH.Type, but it lives inMetaMand generatesCoreinstead of a quote.
The same refactoring applies to Exp etc. I think this would yield an enormous simplification of GHC.HsToCore.Quote.
Edited by Sebastian Graf