John Blackbox | 18 Jul 20:11 2013
Picon

Generating Haskell Code out of Haskell AST (GHC API)

Hi! 
I dont know GHC API very well, but I want to generate AST of a program using GHC API.
Is there any standard method to generate Haskell code out of it? (something like "print_this_for_me_please" function? :D
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Antoine Latter | 19 Jul 04:00 2013
Picon

Re: Generating Haskell Code out of Haskell AST (GHC API)

The package haskell-src-exts is a lot less intimidating if all you are
trying to do is programmatically generate Haskell source:

http://hackage.haskell.org/package/haskell-src-exts

The base types are here:
http://hackage.haskell.org/packages/archive/haskell-src-exts/1.13.5/doc/html/Language-Haskell-Exts-Syntax.html#t:Module

This module has some helper function for generating parts of the AST:
http://hackage.haskell.org/packages/archive/haskell-src-exts/1.13.5/doc/html/Language-Haskell-Exts-Build.html

On Thu, Jul 18, 2013 at 1:11 PM, John Blackbox
<blackbox.dev.ml <at> gmail.com> wrote:
> Hi!
> I dont know GHC API very well, but I want to generate AST of a program using
> GHC API.
> Is there any standard method to generate Haskell code out of it? (something
> like "print_this_for_me_please" function? :D
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe <at> haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
John Blackbox | 19 Jul 10:09 2013
Picon

Re: Generating Haskell Code out of Haskell AST (GHC API)

Thank you!
So, if I'm writing a compiler of custom language, which I want to generate Haskell AST and further compile it with GHC, you prefer something like haskell-src-exts over pure GHC API?


2013/7/19 Antoine Latter <aslatter <at> gmail.com>
The package haskell-src-exts is a lot less intimidating if all you are
trying to do is programmatically generate Haskell source:

http://hackage.haskell.org/package/haskell-src-exts

The base types are here:
http://hackage.haskell.org/packages/archive/haskell-src-exts/1.13.5/doc/html/Language-Haskell-Exts-Syntax.html#t:Module

This module has some helper function for generating parts of the AST:
http://hackage.haskell.org/packages/archive/haskell-src-exts/1.13.5/doc/html/Language-Haskell-Exts-Build.html


On Thu, Jul 18, 2013 at 1:11 PM, John Blackbox
<blackbox.dev.ml <at> gmail.com> wrote:
> Hi!
> I dont know GHC API very well, but I want to generate AST of a program using
> GHC API.
> Is there any standard method to generate Haskell code out of it? (something
> like "print_this_for_me_please" function? :D
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe <at> haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>

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

Gmane