[Haskell-cafe] Generating Haskell Code out of Haskell AST (GHC API)

Joachim Breitner mail at joachim-breitner.de
Fri Jul 19 15:23:41 CEST 2013


Am Freitag, den 19.07.2013, 11:19 +0200 schrieb John Blackbox:

> The question about generating the code was only to have a "debugging
> tool" - to see if the generated AST is good - I wanted to generate the
> Haskell code only to check if its correct, but normally I would not do
> it, because it makes no sense to generate AST -> code -> AST (by GHC)
> again etc :)

it does make sense: ASCII (or today, Unicode text) is a much easier and
more stable interface than some ADT of a library. There is a good reason
why GHC generates llvm files and calls clang on them, instead of
generating the LLVM AST with some libllvm. Same for all the
pre-processors (happy, alex) – they all go through the serialized form.
It will be easier to plug components together, to inspect the
intermediate Haskell code or even modify it.

Of course if you need features not available via the command line, using
the API might be required. But for your own sake I suggest you avoid it
if possible.


Joachim “nomeata” Breitner
  mail at joachim-breitner.dehttp://www.joachim-breitner.de/
  Jabber: nomeata at joachim-breitner.de  • GPG-Key: 0x4743206C
  Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130719/95007009/attachment.pgp>

More information about the Haskell-Cafe mailing list