4

As part of a research project on property-based testing, I need to do static whole-program analysis of Haskell programs. I'm looking for suggestions on how to implement whole-program analysis of Haskell programs, hopefully without building lots of infrastructure myself.

I looked at Template Haskell, which has many of the capabilities I need, but is missing a key feature: in Template Haskell as implemented in GHC, there appears to be no way to get the definition of a function by name. (Related SO question: How to get the declaration of a function using `reify`?)

I suspect that there might be some way of doing whole-program analysis of Haskell programs using the GHC API, but I can't easily determine how this might be done from the GHC API documentation.

In particular, given a function call site, I need to be able to look up the corresponding function definition(s). I'm especially interested in Template Haskell or GHC API-based solutions.

Is there any way to do whole-program analysis of Haskell programs without building all the infrastructure myself?

Community
  • 1
  • 1
Brad Larsen
  • 995
  • 1
  • 12
  • 20
  • Is parsing the source code and looking up the definitions of functions an option? – user2407038 May 19 '14 at 00:55
  • I'd think a library like haskell-src-exts would help here if you wanted to parse the code yourself. – bheklilr May 19 '14 at 13:19
  • user2407038, I'd consider parsing the source code an option. Although it seems that an option like that could result in a different build configuration than you get when building a library with cabal, for example. – Brad Larsen May 19 '14 at 15:14
  • Like bheklilr said, take a look at haskell-src-exts, and if you would like to use TH, also at haskell-src-meta, which parses with haskell-src-exts and converts the AST to the datatype used in TH. I'm afraid I don't know what you mean by different build configuration. – user2407038 May 19 '14 at 18:48

0 Answers0