[ANN] First release of Pp, a pretty-printing library


I’m happy to announce the first release of the pp library! This library provides a lean alternative to the Format module of the standard library. It uses the same comcepts of boxes and break hints, however it defines its own algebra which some might find easier to work with and reason about. I personally do :slight_smile: The final rendering is still done via a formatter which makes it easy to integrate Pp in existing programs using Format.

We introduced this module in Dune to help improve the formatting of messages printed in the terminal and it has been a success. The new API is smaller, simpler and makes it easy for developers to do the right thing. Once the Pp module of Dune was mature enough, we decided to extract it into a separate library so that it could benefit others.

The library itself is composed of a single Pp module and has no dependencies. Its documentation is self-contained and no previous knowledge is required to start using it, however the various guides for the Format module such as this one should be applicable to Pp as well.

If you have used Format before and like me found its API complicated and difficult to use, I hope that you will find Pp nicer to work with!




Another great resource for understanding the core mental model of Format is Format Unraveled, although if I understand pp correctly the discussion about Format not being document-based won’t apply to pp.

Pretty exciting! Is the pp name for the github project final though? For me it feels like this will be an ungoogleable term in the future (even in combination with github and ocaml)?

@jjb indeed. Right now the only way to render is via the Format module, so pp still has the same limitations as Format. But we could lift them in the future by adding another renderer in pp. I suppose the same could be done in Format directly, however with pp the contract is clear that one is constructing a full document in memory before rendering it.

@ryyppy well, I don’t have a great history for choosing software names :slight_smile: Dune was initially called “jbuilder” and I the initial name I proposed for Base was “Alpha”. So if someone has a better name to propose I’m all ears. That being said, pp is the second result when I google “ocaml pp”.

This looks very good for creating CLIs, I’ll try to give it a spin.

Regarding the name, consider using “press”: it prepares text for printing, it’s a pronounceable name, and there’s nothing in the ecosystem using it right now.

1 Like

“press” sounds nice :slight_smile: I’ll keep it in mind. For now I’ll just wait and see how things go.