[GHC] #11078: Access to module renaming with reifyModule, in TemplateHaskell

GHC ghc-devs at haskell.org
Wed Nov 11 05:44:41 UTC 2015


#11078: Access to module renaming with reifyModule, in TemplateHaskell
-------------------------------------+-------------------------------------
           Reporter:  cipher1024     |             Owner:
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Template       |           Version:  7.10.2
  Haskell                            |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 I am writing a bit of TemplateHaskell for stringing together QuickCheck
 style specifications. I require every module containing properties to
 export a symbol called ''axiom_set''. Then, my checkAxioms function finds
 all the ''axiom_set'' symbols from modules imported where I call
 checkAxioms.

 checkAxioms :: DecsQ
 checkAxioms = do
     ModuleInfo ms <- reifyModule =<< thisModule
     forM_ ms $ \mi@(Module _ m) -> do
         runIO . print =<< lookupValueName (modString m ++ ".axiom_set")

 The above code should find all the imported "axiom_set" symbols. However,
 if Module.Axioms defines axiom_set but that I imported as follows

 import Module.Axioms as MA

 my code can't find MA.axiom_set.

 I think either modString should return MA in the case of Module.Axioms or
 there should be a function that takes a symbol and a module and constructs
 a Name referring to the symbol in the module and considering possible
 renamings of modules.

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


More information about the ghc-tickets mailing list