roc-lang / book-of-examples

Software Design by Example in Roc
Other
21 stars 14 forks source link

topic: pretty-printing library #57

Open abhin4v opened 2 weeks ago

abhin4v commented 2 weeks ago

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:

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.

gvwilson commented 2 weeks ago

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

rtfeldman commented 2 weeks ago

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.