Hostname: page-component-7c8c6479df-5xszh Total loading time: 0 Render date: 2024-03-28T20:04:29.055Z Has data issue: false hasContentIssue false

Linear, bounded, functional pretty-printing

Published online by Cambridge University Press:  01 January 2009

S. DOAITSE SWIERSTRA
Affiliation:
Utrecht University, The Netherlands
OLAF CHITIL
Affiliation:
University of Kent, UK
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

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.

Type
Functional Pearls
Copyright
Copyright © Cambridge University Press 2008

References

Bird, Richard S. (1984) Using circular programs to eliminate multiple traversals of data. Acta Inf. 21, 239250.Google Scholar
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.Google Scholar
Chitil, Olaf. (2005) Pretty printing with lazy dequeues. Trans. Prog. Lang. Syst. 27 (1), 163184.Google Scholar
Chitil, Olaf. (2006) Pretty Printing with Delimited Continuations. Technical Report 4-06. Computing Laboratory, University of Kent.Google Scholar
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.Google Scholar
Okasaki, Chris. (1998) Purely Functional Data Structures. Cambridge, UK: Cambridge University Press.Google Scholar
Oppen, Dereck C. (1980) Pretty-printing. {ACM} Trans. Prog. Lang. Syst. 2 (4), 465483.Google Scholar
PeytonJones, Simon L. Jones, Simon L. (1997) A Pretty Printer Library in {H}askell. Part of the GHC distribution at http://www.haskell.org/ghc.Google Scholar
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.Google Scholar
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.Google Scholar
Wadler, Philip. (2003) A prettier printer. In The Fun of Programming, Gibbons, Jeremy & Oege de, Moor (eds). Hampshire: Palgrave Macmillan, pp. 223244.Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.