I am trying to parse Haskell source code and generate a decision tree to analyze different paths Haskell programs can take.
haskell-src-exts gives a reasonable representation, but does not have any type information associated with it.
Does GHC or some other tool provide that functionality?
1 Answer
There's no tool except GHC that is particularly adept at typechecking Haskell source at the moment. A haskell-type-exts was in development to match src-exts, but it was never completed.
So you can use a reasonable wrapper to the GHC API, such as hint, and invoke it on the subexpressions you want to check using its type inference api.
This is a rather painful approach, but I can't think of much better. If you're only interested in working on haskell-like code as an exercise, you could instead import the PureScript compiler as a library, and then you'll be able to get a fully type annotated syntax tree in a more reasonable way.
Alternately, you can try to navigate the thicket of the GHC api itself to get fully typechecked source...
If you choose to go that route, this answer may get you started.
ghc-modpackage.