Conversation

I think this is essentially "finally tagless": instead of defining your structures (AST or IR) as data, define them as classes; in the parser resp. elaborator, "construct" the AST resp. IR by calling methods; make instances do elaboration, resp. perhaps code generation, directly.
1
1
You can also define instances to construct an actual AST/IR as data, if you need that, for example to do analysis/optimization. (I'm not sure if you couldn't also do those as a directly fused chain, but I'm pretty sure you couldn't if you need to compute fixed points.)
2
1
You might inspire me to try this again though - I think it could be super fun to try, even with something like STLC. Would be cool if you could fuse ANF, closure conversion, SSA, etc all the way down.
1
1
Show replies
Replying to and
I've been wanting to try implementing this myself, but haven't done so yet... there may be wrinkles. :) Maybe you'd need to add the notion of a context explicitly as part of the classes' APIs? (and tl;dr on that link, alas)
1