intlc icon indicating copy to clipboard operation
intlc copied to clipboard

Prettified codegen

Open samhh opened this issue 3 years ago • 2 comments

It's all on a single line at the moment. We'll probably run Prettier against it in web, but ideally the output would be more legible out of the box.

samhh avatar Jan 14 '22 20:01 samhh

This'd also make golden test output diffs more legible.

samhh avatar Feb 07 '22 23:02 samhh

I guess one way to implement this would be to convert the JS Compiler from Reader Cfg to RWS Cfg () State where State tracks indent level. Then wherever there's an indentable block, like opening a function body in a switch statement, we call a helper indent :: Compiler a -> Compiler a which increments the state, compiles the contents with indentation, and then decrements on the way back out - similar to withPluralCtx in Intlc.Parser.

Edit: Can use Reader local for this, see #173.

samhh avatar Feb 07 '22 23:02 samhh