Skip to main content

Linear, bounded, functional pretty-printing


We present two implementations of Oppen's pretty-printing algorithm in Haskell that meet the efficiency of Oppen's imperative solution but have a simpler and a clear structure. We start with an implementation that uses lazy evaluation to simulate two co-operating processes. Then we present an implementation that uses higher-order functions for delimited continuations to simulate co-routines with explicit scheduling.

Hide All
Bird, Richard S. (1984) Using circular programs to eliminate multiple traversals of data. Acta Inf. 21, 239250.
Chitil, Olaf. (2001) Pretty printing with lazy dequeues. In ACM Sigplan Haskell Workshop, Hinze, Ralf (ed). Utrecht University Utrecht, pp. 183201. UU-CS, no. 23.
Chitil, Olaf. (2005) Pretty printing with lazy dequeues. Trans. Prog. Lang. Syst. 27 (1), 163184.
Chitil, Olaf. (2006) Pretty Printing with Delimited Continuations. Technical Report 4-06. Computing Laboratory, University of Kent.
Hughes, John. (1995) {T}he {d}esign of a {p}retty-printing {l}ibrary. In Advanced Functional Programming, Jeuring, J. & Meijer, E. (eds), LNCS, vol. 925. Berlin: Springer-Verlag.
Okasaki, Chris. (1998) Purely Functional Data Structures. Cambridge, UK: Cambridge University Press.
Oppen, Dereck C. (1980) Pretty-printing. {ACM} Trans. Prog. Lang. Syst. 2 (4), 465483.
PeytonJones, Simon L. Jones, Simon L. (1997) A Pretty Printer Library in {H}askell. Part of the GHC distribution at
Swierstra, S. D. (2004) Linear, Online, Functional Pretty Printing (Corrected and Extended Version). Technical Report UU-CS-2004-025a. Institute of Information and Computing Sciences, Utrecht University.
Swierstra, S. D., AzeroAlocer, P. R. Alocer, P. R. & Saraiva, J. (1999) Designing and implementing combinator languages. In Advanced Functional Programming, Third International School, {AFP}'98, Swierstra, Doaitse, Henriques, Pedro, & Oliveira, José (eds), LNCS, vol. 1608. Berlin: Springer-Verlag, pp. 150206.
Wadler, Philip. (2003) A prettier printer. In The Fun of Programming, Gibbons, Jeremy & Oege de, Moor (eds). Hampshire: Palgrave Macmillan, pp. 223244.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *


Altmetric attention score

Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed

Linear, bounded, functional pretty-printing

Submit a response


No Discussions have been published for this article.


Reply to: Submit a response

Your details

Conflicting interests

Do you have any conflicting interests? *