In TemplateHaskell, how can I understand that the imported module has been renamed?

I am writing a little TemplateHaskell to overlay QuickCheck style specifications together. I require that each module containing properties export a symbol called axiom_set. Then my checkAxioms function finds all the "axiom_set" characters from the imported modules, 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 characters. However, if Module.Axioms defines axiom_set, but I imported it as follows

import Module.Axioms as MA

my code cannot find MA.axiom_set. Any tips?

+4
source share
1 answer

, . , -, TemplateHaskell.

, ModuleInfo , , lookupValueName, . , lookupValueName lookupName, Module.

GHC: https://ghc.haskell.org/trac/ghc/newticket TH . , .. .

+3

Source: https://habr.com/ru/post/1615319/


All Articles