Need help with GHC API and GHC internals

Simon Peyton-Jones simonpj at
Mon Aug 4 07:46:55 EDT 2008

* Claus is right to say that you want the *renamed* tree, not the *parsed* tree.

* He's also right to point to the under-development generic programming stuff for the GHC API.  I'm not certain about how settled they are right now though.

* But in fact you can get exactly what you want from the mg_used_names fields of the ModGuts (post desugaring).


| -----Original Message-----
| From: glasgow-haskell-users-bounces at [mailto:glasgow-haskell-users-bounces at] On
| Behalf Of Mark Tullsen
| Sent: 02 August 2008 04:06
| To: glasgow-haskell-users at
| Subject: Need help with GHC API and GHC internals
| 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
| 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.
|   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

More information about the Glasgow-haskell-users mailing list