Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to main content

The design of a pretty-printing library

  • Conference paper
  • First Online:
Advanced Functional Programming (AFP 1995)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 925))

Included in the following conference series:

  • 2332 Accesses

Abstract

In this chapter we have considered the design of combinator libraries. We saw how studying the algebraic properties of the combinators desired can both help to suggest natural choices of representation, and guide the implementation of the operators. We saw several examples — lists, monads, and a pretty-printing library. For this kind of program development we need a language with higher-order functions and lazy evaluation, for which equational reasoning is valid; in other words, Haskell is ideally suited.

In the case of pretty-printing, studying the algebra led to the correction of a subtle error in the combinators' behaviour, and to the development of much more efficient implementations. The pretty-printing algebra is just too intricate to rely on intuition alone: working informally I could not see how to implement the optimisation considered in section 9, nor could I invent the representation used there. The formal approach has been invaluable.

The pretty-printing library itself has proved useable, despite its simplicity. Indeed, versions of it have seen quite extensive use, in program transformation tools, proof assistants, and compilers. All the pretty-printers in both the Chalmers and the Glasgow Haskell compilers are written using variants of this design.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Similar content being viewed by others

References

  1. Lennart Augustsson, Haskell B. user's manual, available over WWW from http://www.cs.chalmers.se:80/pub/haskell/chalmers/.

    Google Scholar 

  2. Konstantin Läufer, Combining Type Classes and Existential Types, Proc. Latin American Informatics Conference (PANEL), ITESM-CEM, Mexico, September 1994.

    Google Scholar 

  3. Derek C. Oppen, Pretty-printing, in ACM Transactions on Programming Languages and Systems, Vol. 2, No. 4, October 1980.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Johan Jeuring Erik Meijer

Rights and permissions

Reprints and permissions

Copyright information

© 1995 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Hughes, J. (1995). The design of a pretty-printing library. In: Jeuring, J., Meijer, E. (eds) Advanced Functional Programming. AFP 1995. Lecture Notes in Computer Science, vol 925. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-59451-5_3

Download citation

  • DOI: https://doi.org/10.1007/3-540-59451-5_3

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-59451-2

  • Online ISBN: 978-3-540-49270-2

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics