
#11078: Access to module renaming with reifyModule, in TemplateHaskell -------------------------------------+------------------------------------- Reporter: cipher1024 | Owner: Type: feature request | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by jstolarek): I just had a quick look at the code. Let's assume we are using definition proposed by Richard (slightly modified by me): {{{#!hs data ImportType = Qualified | Unqualified deriving( Show, Eq, Ord, Data, Typeable, Generic ) data ModuleImport = ModuleImport Module -- ^ Imported module ImportType -- ^ qualified? (Maybe String) -- ^ synonym [Name] -- ^ imported names deriving( Show, Eq, Ord, Data, Typeable, Generic ) }}} I understand that the place where we need to fill in these fields is `TcSplice.reifyModule`. At least that is the place where the build fails for me after I make changes to TH syntax. In `TcM` we have access to `getImports`, which gives us a list of `Module`s, each with an assigned `ImportedModsVal`: {{{#!hs type ImportedMods = ModuleEnv [ImportedModsVal] data ImportedModsVal = ImportedModsVal { imv_name :: ModuleName, -- ^ The name the module is imported with imv_span :: SrcSpan, -- ^ the source span of the whole import imv_is_safe :: IsSafeImport, -- ^ whether this is a safe import imv_is_hiding :: Bool, -- ^ whether this is an "hiding" import imv_all_exports :: GlobalRdrEnv -- ^ all the things the module could provide } }}} Now, in `reifyModule` we need the following: 1. `Module`: this is readily available and created by the existing implementation (see `TcSplice.modToTHMod`. 2. `ImportType`: I can't figure out how we could acces that one 3. `Maybe String`, aka the module synonym. I would look at `imv_name` to see what exactlt it holds. Also, I would adjust TH representation to work nicely with information stored in that field. 4. `[Name]` - it seems that this can be extracted from `imv_all_exports`. Does that allow to make progress? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11078#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler