happy icon indicating copy to clipboard operation
happy copied to clipboard

Default backend should generate TemplateHaskell and write that to a file

Open sgraf812 opened this issue 4 years ago • 3 comments

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.

sgraf812 avatar Apr 25 '21 17:04 sgraf812

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.

phadej avatar Apr 25 '21 17:04 phadej

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

int-index avatar Apr 25 '21 18:04 int-index

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.

Ericson2314 avatar Apr 25 '21 20:04 Ericson2314