Need help with GHC API and GHC internals
Claus Reinke
claus.reinke at talk21.com
Sat Aug 2 05:03:11 EDT 2008
> API. I.e., for each top level value definition, I want a list of the
> top-level names used in the definition.
>
> Using GHC API, once I have a 'CheckedModule', I have a dilemma:
> a) If I use this field
> parsedSource :: ParsedSource
> I've got a giant AST that I need to traverse for names, there
> being no help in the compiler to do so, AFAIK.
Have a look at http://hackage.haskell.org/trac/ghc/wiki/GhcApiAstTraversals
and its attachments (Instances.hs/Instances0.hs provides some Data/Typeable
instances for Ghc's Ast types using standalone deriving, Utils.hs/APSSybTesting.hs
show some uses). There seems to be agreement that Data/Typeable instances
(though not necessarily these) should come with the Ghc Api in the future.
If you stop with the parsed AST, there is no scope information, so
you might still want to use the output of later phases for your task
(renamedSource might be suitable).
Hth,
Claus
> b) If I use this field
> coreBinds :: Maybe [CoreBind]
> although I've got a simpler type to deal with, and some useful
> functions
> (e.g. exprFreeNames), I believe I'm now swimming in waters a bit
> deep for me or maybe this is just a flawed approach:
> - the core bindings created do not correspond exactly to the
> bindings
> in the source and 'exprFreeNames' is acting in surprising ways.
> - etc, etc.
>
> Does anyone have any advice for me here? Is there some way I can get
> approach
> (b) to work without becoming a wizard in GHC internals? Is there
> anything I'm
> missing?
>
> Thanks,
>
> Mark
>
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
More information about the Glasgow-haskell-users
mailing list