tcr / corollary

Cross-compiler from Haskell to Rust, plus parser-haskell.
73 stars 5 forks source link

Preliminary std::fmt-based output #57

Closed pshc closed 7 years ago

pshc commented 7 years ago

Here's a demonstration of how we could revamp our output.

Once all the old String-based output is gone, we wouldn't have to pass around PrintState anymore. (Although I suspect we may end up passing around some Env struct with in-scope bindings instead...?)

tcr commented 7 years ago

I like this, essentially we break the print_X methods into convert_X and the corresponding ir:: output methods, yes?

An environment struct with scoped bindings is likely, a few pointfree functions will need that context to output properly. Also, I'd be good with moving mod ir into its own file now, since main.rs (as you imagine) is getting unwieldy.

If you think this can be done piecemeal, we can merge this now. Or lmk if you want to hold off after proving out the concept.

pshc commented 7 years ago

Yep, correct! Piecemeal is good. I'll go into a holding pattern and try again after we have clearer skies.

tcr commented 7 years ago

Merging. This is the right pattern to build toward and it passes tests, so 💯

pshc commented 7 years ago

Oh cool! OK. Let me push a commit to master that'll move it to a separate file.