News for hackers. Stuff that matters.
Re:The Hardest Program I've Ever Written (2015) by harpocrates on Monday August 21, 2017 @03:30PM (#15067094)
Pretty-printing is tough. That said, please don't reinvent the wheel. There is research that has gone into this that should make most of this stuff pretty straightforward. I personally recommend Wadler's "A Prettier Printer" [0] (although credit goes to Hughes for laying a lot of the groundwork [1]). It too uses an IR and has several possible heuristics for rendering.

I've been using an implementation of it [2] with a lot of success for pretty printing Rust code [3].

  [0]: https://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf
  [1]: http://belle.sourceforge.net/doc/hughes95design.pdf
  [2]: https://hackage.haskell.org/package/prettyprinter
  [3]: https://github.com/harpocrates/language-rust

There are no comments on this comment yet.