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

GHC ghc-devs at haskell.org
Thu May 7 02:56:16 UTC 2015


#10391: Ability to get contents of TH reified module
-------------------------------------+-------------------------------------
              Reporter:  dmcclean    |             Owner:
                  Type:  feature     |            Status:  new
  request                            |         Milestone:
              Priority:  low         |           Version:
             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:              |
-------------------------------------+-------------------------------------
 After using reifyModule, I'd like to be able to inspect the list of
 exports from that module.

 At first I thought that this could perhaps be done by changing from
 {{{#!hs
 data ModuleInfo =
   -- | Contains the import list of the module.
   ModuleInfo [Module]
 }}}

 to

 {{{#!hs
 data ModuleInfo =
   -- | Contains the import list and export list of the module.
   ModuleInfo [Module] [Name]
 }}}

 but I now wonder if this is the best plan, because `thisModule >>=
 reifyModule` might be expected to function as a time machine, allowing us
 to see declarations that may not have been made yet (in the case where
 this module's export list is implicit).

 Can anyone propose a type that would allow us to perform this inspection
 for modules that have already been baked, but not for "this" module?

 An intended use case would be in our dimensional types library. We have
 several modules that define a whole bunch of units. It's useful for the
 unit name parser to have access to a dictionary with all of those units in
 it, but maintaining the definition of such a dictionary is redundant. If
 this feature existed, a module in the parser could import the modules
 where units are defined, examine the export lists, reify the names in the
 export lists, determine which represent unit definitions, and emit a
 declaration of a dictionary that contains them all.

 (This is in some ways similar to #9699, though perhaps more difficult?)

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


More information about the ghc-tickets mailing list