[Haskell-cafe] GHC API: how to get the typechecked AST?

Gerbo Engels gcengels at cs.uu.nl
Fri May 9 10:02:14 EDT 2008


Hello all,

In the GHC Commentary [1] I can read that the type checker adds type
information to the syntax tree. So I would expect that there is a way to
get a syntax tree of type HsModule Id.
The GHC API provides functions checkModule and checkAndLoadModule which
both return a CheckedModule that contains the parsedSource :: Located
(HsModule RdrName) and typecheckedSource :: LHsBinds Id. But it doesn't
include anything of type HsModule Id. I don't see how to unify the
parsedSource and typecheckedSource to get the syntax tree parametrised by
Id instead of RdrName (and containing the type information), and the API
doesn't seem to provide such functionality (or did I miss something?).

Can anyone help? Or indicate where in the parsedSource the LHsBinds should
be placed?

Regards,
Gerbo Engels

[1]
http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/HsSynType#DecoratingHsSynwithtypeinformation



More information about the Haskell-Cafe mailing list