On Tue, 13 Dec 2011 18:16:17 +0100, Sh NJP <shayan....@gmail.com> wrote:
> I do some pre-processing on a normal Haskell code ( -F ). The pre-processor
> needs to know the type of each expression.
> What are the possibilities to do so?
> Can I use GHC API to employ GHC type checker? If yes, any good tutorial?
> Is it too naive to think of a function, f :: String -> AnnotatedAST , that
> takes Haskell code and returns its corresponding abstract syntax tree
> annotated with types?

Another, less powerful, but much easier approach would be to use hint,
which also provides some type-checking functionality. Unfortunately, the
results seem to be just Strings:

http://hackage.haskell.org/packages/archive/hint/0.3.3.3/doc/html/Language-Haskell-Interpreter.html#g:7

If you want to see more examples of using the GHC API, you could also
take a look at the ghc-mod repository on github, which uses the GHC API
to provide type information to Emacs:

https://github.com/kazu-yamamoto/ghc-mod

Cheers,
Daniel

Attachment: pgpBVUtUkkqQF.pgp
Description: PGP signature

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to