Pretty-printing: An Exercise in Functional Programming

We designed a very small library (around one page) defining five combinators for pretty-printing. Despite, or perhaps because of their simplicity, these combinators have proved sufficiently efficient and expressive for quite extensive practical use. The combinators are simple to specify and enjoy many algebraic properties. The algebra is useful for reasoning about pretty-printers that use the library, and played an important role in deriving its implementations.