4 ms·
I really have to back up the recommendation for Wadler's "prettier printer" paper. I'm working on a Haskell parser and pretty-printer for Rust and I had pretty
by harpocrates 10y ago
I really have to back up the recommendation for Wadler's "prettier printer" paper. I'm working on a Haskell parser and pretty-printer for Rust and I had pretty much given up on ever finding a lightweight pretty printer that would be able to choose whether to put something on one line or to split it up into multiple lines all by itself. For anyone needing this in Haskell, I strongly urge you to consider the modern rewrite of the initial library [1].
[1] https://hackage.haskell.org/package/wl-pprint-annotated https://hackage.haskell.org/package/wl-pprint-annotated
- bjz_ 10y agoYeah, I can second that recommendation on reading the paper [0]. It's one of the nicest I've read. There is also a Rust crate for it[1] - though it's not as... 'pretty'... as the Haskell EDSL, obviously. [0]: http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettie... [1]: https://crates.io/crates/pretty https://crates.io/crates/pretty
- erikpukinskis 10y agoI think there's beauty in the best you can do with a very simple implementation. Even if you can improve "prettiness" with heroic technical efforts, I think the end result would be uglier. There's something special about simple rules coming together to address just the most important needs. In the tech world, we tend to put more finesse into things... because we can. But as a result, most software is over-finessed and therefore not finessed at all. A great example is how tortured we let our CSS rules get, rather than allowing a design to relax a little into the constraints of the layout engine. A hand-set newspaper isn't beautiful because it overcame every constraint, it's beautiful because it accepted its constraints, and made hard tradeoffs in service of a goal.