The Design of a Pretty-printing Library (1995) [67 citations — 2 self]
Abstract:
Layouts We'll begin by looking for an abstract model of a pretty-printer's output --- that is, prettily indented text. We could say that the output is just a string, but a string has so little structure that we can derive no intuition from it. Let us say instead, that a layout is a sequence of indented lines, which we can model as type Layout = [(Int; String)] + Notice that we shall allow indentations to be negative: later on this will contribute to a nicer algebra, just as integers have a nicer algebra than natural numbers. But notice also that we restrict layouts to be non-empty (we use [\Gamma] + for the type of non-empty lists). We'll return to this point below. We can now specify text, nest and ($$) very easily: text s = [(0; s)] nest k l = [(i + k; s)j(i; s) / l] l 1 $$ l 2 = l 1 ++l 2 The right definition of horizontal composition (!?) is not so obvious. The desired behaviour is clear enough when text s is placed beside text t, but what if both layouts are indented? W...
Citations
| 8 | Combining type classes and existential types – Laufer - 1994 |

