book-of-examples icon indicating copy to clipboard operation
book-of-examples copied to clipboard

topic: pretty-printing library

Open abhin4v opened this issue 1 year ago • 2 comments

The idea is to implement a pretty printing library based on Philip Wadler's "A prettier printer" paper.

The paper already contains code for an implementation, though it is a bit rudimentary. The wl-print Haskell package contains an extension of it, with some extra bells and whistle for convenience.

We can stick with the paper's implementation or something in-between that and wl-print's. We would also demonstrate the library usage by pretty printing one of these:

  • An ADT, such as the JSON value representation
  • An AST representation of s-exps (simple AST)
  • An AST representing some simple imperative language (complex AST)

This has been done before in the chapter 5 of the Real World Haskell book.

The Roc implementation may not be exactly same as the Haskell implementations because of strict-vs-lazy nature of the two languages.

abhin4v avatar Apr 15 '24 13:04 abhin4v

:+1: I like this one, and I think it's about the right size - @rtfeldman @Anton-4 thoughts?

gvwilson avatar Apr 16 '24 17:04 gvwilson

Sounds good to me! There was a blog post recently on how to take the ideas in that paper a step further, but I don't have a link handy. It gave examples in Rust, which might be easier to port to Roc because they're strictly evaluated.

rtfeldman avatar Apr 16 '24 18:04 rtfeldman