[GHC] #10391: Ability to get export list of TH reified module

GHC ghc-devs at haskell.org
Thu May 7 16:57:08 UTC 2015


#10391: Ability to get export list of TH reified module
-------------------------------------+-------------------------------------
        Reporter:  dmcclean          |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  low               |               Milestone:
       Component:  Template Haskell  |                 Version:
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by dmcclean):

 I'm not sure how strong the connection to #1475 is, because that ticket is
 about writing new exports in splices, whereas this one is about reading
 existing splices.

 I'd like to take a swing at this one, and I've just traced through enough
 of the code to have a good plan of attack, but I barely even know where to
 start to tackle #1475, so if you feel strongly that there's something to
 be gained by attacking both at once then I may not be the man for the job.
 (Which isn't to say that I won't try, just that I might need considerable
 help getting up to speed.)

 Setting aside #1475, on this one the meat of it happens
 [here](https://github.com/ghc/ghc/blob/4efa421327cf127ebefde59b2eece693e37dc3c6/compiler/typecheck/TcSplice.hs#L1525-L1533):

 {{{#!hs
 reifyThisModule = do
   usages <- fmap (map modToTHMod . moduleEnvKeys . imp_mods) getImports
   return $ TH.ModuleInfo usages

 reifyFromIface reifMod = do
   iface <- loadInterfaceForModule (ptext (sLit "reifying module from TH
 for") <+> ppr reifMod) reifMod
   let usages = [modToTHMod m | usage <- mi_usages iface,
                                Just m <- [usageToModule (modulePackageKey
 reifMod) usage] ]
   return $ TH.ModuleInfo usages
 }}}

 My plan would be to extend the `reifyFromIface` bit to bind the exported
 names from the `AvailInfo`s in the `mi_exports` field of `iface`,
 flattening them into a list of names. (I'm not sure quite how to get from
 `Name.Name` to `Language.TH.Syntax.Name` though...) Then I would add the
 list of names to the `TH.ModuleInfo`.

 I would extend the `reifyThisModule` bit to `TH.ModuleInfo usages (error
 "Accessing the list of names exported by the current module is not
 supported.")`, or something to that effect. I assume there are style
 conventions on how to write such errors, I could use a pointer on where to
 look for that.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10391#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list