[Haskell-cafe] Whole program analysis as a GHC plugin

David Darais darais at cs.umd.edu
Mon Mar 16 17:34:53 UTC 2015


Hello cafe,

I'm currently implementing a whole-program analysis for Haskell programs using the GHC api. I have a GHC plugin written and I'm successfully slurping in programs and processing them with my analysis tools.

I'm getting stuck when my tool encounters an identifier that lives in another module. I'd like to unfold the identifier and retrieve its source code, allowing me to do whole-program analysis.

Assuming I have the source code of the whole program, and that I get to (re)compile everything with my plugin enabled, I'm wondering:

1) Does the GHC api already support a nice way of doing this?
2) I see that there is support for unfolding identifiers if they've been specially marked in .hi files. Is there a way to mark everything to support unfolding, and would this give me the information I'm looking for?
3) Does anybody have experience with implementing a whole-program analysis for GHC as a plugin, and if so, how did you go about it?

Many Thanks,
David


More information about the Haskell-Cafe mailing list