haskell / happy

The Happy parser generator for Haskell
Other
276 stars 85 forks source link

Default backend should generate TemplateHaskell and write that to a file #190

Open sgraf812 opened 3 years ago

sgraf812 commented 3 years ago

Although the current practice of simply concatenating Strings and dumping the result in a .hs file is simple, I think the general plan should be to do all the staging as part of (Typed?) Template Haskell meta programming. A very reasonable step in-between is to generate a TH AST in the backend which is subsequently pretty-printed to generate the .hs file.

phadej commented 3 years ago

I wonder, @RyanGlScott could clarify, how well the "pretty printing TH expressions / declarations roundtrips".

I recall he spend some time fixing issues, and I'm pretty sure that is subtle.

I mean, that is great, but probably template-haskell "maintainers" (which AFAIK is Ryan alone?) should be aware of this "real production" use scenario.

int-index commented 3 years ago

The problem is that Happy does not parse/rename the source code, so it cannot embed it in the TH AST.

Ericson2314 commented 3 years ago

I want to give the TH AST extension constructors (Void by default) so arbitrary stuff can be interleaved with the TH AST then printed back.

That would mean happy can use TH and yet also work as is.