[GHC] #9699: TH function to list names in scope

GHC ghc-devs at haskell.org
Sat Jun 20 09:35:34 UTC 2015


#9699: TH function to list names in scope
-------------------------------------+-------------------------------------
        Reporter:  MikeIzbicki       |                   Owner:
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Template Haskell  |                 Version:  7.8.3
      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 spinda):

 Attempt at a rough specification:

 (1) Extend [https://hackage.haskell.org/package/template-
 haskell-2.10.0.0/docs/Language-Haskell-TH-Syntax.html#t:ModuleInfo
 ModuleInfo] (obtained from [https://hackage.haskell.org/package/template-
 haskell-2.10.0.0/docs/Language-Haskell-TH-Syntax.html#v:reifyModule
 reifyModule]) to {{{ModuleInfo [Module] [Name]}}}, where {{{[Module]}}} is
 still the import list and {{{[Name]}}} contains the module's list of
 exported names.

 (2) Add {{{thisModule :: Q Module}}} producing the current
 [https://hackage.haskell.org/package/template-haskell-2.10.0.0/docs
 /Language-Haskell-TH-Syntax.html#t:Module Module].

 (3) Add {{{topLevelNames :: Q [Name]}}} producing a list of top-level
 names (both exported and non-exported) bound in the current module that
 would be visible to {{{reify}}}.

 (4) Add {{{nestedNames :: Q [Name]}}} (in need of a better name) producing
 a list of the non-top-level (nested) names visible to {{{reify}}} in this
 context.

 (5) Add {{{parentNames :: Q [Name]}}} (also in need of a better name)
 producing a list of the names immediately associated with the current
 splicing context, if available. For example, {{{foo, bar ::
 $(typeSplice)}}} would see {{{foo}}} and {{{bar}}}, {{{foo =
 $(exprSplice)}}} would see {{{foo}}}, and {{{$(topLevelDecSplice)}}} would
 see {{{[]}}}.

 (6) ''Optional'' Add {{{isTopLevel :: Name -> Q Bool}}} to detect whether
 a name is bound at the top level (of the current module?). Something like
 this could alternately be accomplished by searching through
 {{{topLevelNames}}}.

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


More information about the ghc-tickets mailing list