School of Computing

Pretty printing with delimited continuations

Olaf Chitil

Technical report 4-06, University of Kent, Computing Laboratory, June 2006.


Pretty printing is the task of nicely formatting tree structured data within a given line width limit. In 1980 Oppen published a pretty printing algorithm that takes time linear in the size of the input, independent of the line width, and uses only limited look-ahead. This work inspired the development of a number of purely functional pretty printing libraries in Haskell. Here I present a new functional pretty printing algorithm that has all the nice properties of Oppen's and is surprisingly simple. A double-ended queue of delimited continuations is the key to addressing all aspects of the problem explicitly.

Download publication 124 kbytes (PDF)

Bibtex Record

author = {Olaf Chitil},
title = {Pretty Printing with Delimited Continuations},
month = {June},
year = {2006},
pages = {182-196},
keywords = {determinacy analysis, Craig interpolants},
note = {},
doi = {},
url = {},
    publication_type = {techreport},
    submission_id = {18750_1151580575},
    type = {Technical report},
    number = {4-06},
    institution = {University of Kent, Computing Laboratory},

School of Computing, University of Kent, Canterbury, Kent, CT2 7NF

Enquiries: +44 (0)1227 824180 or contact us.

Last Updated: 21/03/2014