Need help with GHC API and GHC internals

Mark Tullsen tullsen at
Fri Aug 1 23:06:00 EDT 2008

I'm attempting to write a call-graph generator for Haskell using the GHC
API. I.e., for each top level value definition, I want a list of the  
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.
  b) If I use this field
       coreBinds         :: Maybe [CoreBind]
     although I've got a simpler type to deal with, and some useful  
     (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  
         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  
(b) to work without becoming a wizard in GHC internals?  Is there  
anything I'm



More information about the Glasgow-haskell-users mailing list