The Design of a Pretty-printing Library

John Hughes


Much of the power of functional programming languages depends on the support they offer for software reuse. To take full advantage of it, the functional programmer should approach a new application area by identifying the programming idioms common in that area, and defining them as (probably) higher-order functions. Each particular application program can then be built largely by combining these functions, rather than writing `new code'. Programming with such an approach is very rapid once the library of combinators is defined, and programs are often correct first time since they are built by assembling correct components.

The question addressed in this paper is: how should libraries of combinators be designed? Our goal is to show how we can use formal specification of the combinators, and a study of their algebraic properties, to guide both the design and implementation of a combinator library. Our case study is a library for pretty-printing. But the methods we present are of wider applicability, and we also show how they can be used to develop a number of different monads.

The paper is available here, and here is a bibtex entry.

John Hughes
Last modified: Fri Aug 9 10:42:27 MET DST 1996