Skip to main content

Lazy v. Yield: Incremental, Linear Pretty-Printing

  • Conference paper
Programming Languages and Systems (APLAS 2012)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 7705))

Included in the following conference series:

Abstract

We propose a programming style for incremental stream processing based on typed simple generators. It promotes modularity and decoupling of producers and consumers just like lazy evaluation. Simple generators, however, expose the implicit suspension and resumption inherent in lazy evaluation as computational effects, and hence are robust in the presence of other effects. Simple generators let us accurately reason about memory consumption. To substantiate our claims we give a new solution to the notorious pretty-printing problem. Like earlier solutions, it is linear, backtracking-free and with bounded latency. It is also simpler to write and reason about, and is compatible with effects including IO, letting us read the source document from a file, and format it as we read.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Hughes, J.: Why functional programming matters. Comput. J. 32, 98–107 (1989)

    Article  Google Scholar 

  2. McIlroy, M.D.: Power series, power serious. J. Funct. Program. 9, 325–337 (1999)

    Article  MATH  Google Scholar 

  3. Bird, R.S.: Using circular programs to eliminate multiple traversals of data. Acta Informatica 21, 239–250 (1984), doi:10.1007/BF00264249

    Article  MATH  Google Scholar 

  4. Viera, M., Swierstra, S.D., Swierstra, W.: Attribute grammars fly first-class: how to do aspect oriented programming in Haskell. In: ICFP, pp. 245–256 (2009)

    Google Scholar 

  5. Henderson, P., Morris Jr., J.H.: A lazy evaluator. In: POPL, pp. 95–103. ACM, New York (1976)

    Google Scholar 

  6. Ariola, Z.M., Maraist, J., Odersky, M., Felleisen, M., Wadler, P.: A call-by-need lambda calculus. In: POPL, pp. 233–246. ACM, New York (1995)

    Google Scholar 

  7. Garcia, R., Lumsdaine, A., Sabry, A.: Lazy evaluation and delimited control. In: POPL, pp. 153–164. ACM, New York (2009)

    Google Scholar 

  8. Chang, S., Van Horn, D., Felleisen, M.: Evaluating Call-by-Need on the Control Stack. In: Page, R., Horváth, Z., Zsók, V. (eds.) TFP 2010. LNCS, vol. 6546, pp. 1–15. Springer, Heidelberg (2011)

    Chapter  Google Scholar 

  9. Kay, M.: You pull, I’ll push: on the polarity of pipelines. In: Proc. Balisage: The Markup Conference. Balisage Series on Markup Technologies, vol. 3 (2009)

    Google Scholar 

  10. Jackson, M.A.: Principles of Program Design. Academic Press, Inc., Orlando (1975)

    Google Scholar 

  11. James, R.P., Sabry, A.: Yield: Mainstream deliminted continuations. In: Theory and Practice of Delimited Continuations (2011)

    Google Scholar 

  12. Clare, A., King, R.D.: Data Mining the Yeast Genome in a Lazy Functional Language. In: Dahl, V. (ed.) PADL 2003. LNCS, vol. 2562, pp. 19–36. Springer, Heidelberg (2002)

    Chapter  Google Scholar 

  13. Kiselyov, O.: Iteratees. In: Schrijvers, T., Thiemann, P. (eds.) FLOPS 2012. LNCS, vol. 7294, pp. 166–181. Springer, Heidelberg (2012)

    Chapter  Google Scholar 

  14. Liskov, B.: A history of CLU. Technical Report 561, MIT LCS (1992)

    Google Scholar 

  15. Shaw, M., Wulf, W.A., London, R.L.: Abstraction and verification in Alphard: defining and specifying iteration and generators. Comm. ACM 20, 553–564 (1977)

    Article  MATH  Google Scholar 

  16. Lato, J.W.: Understandings of iteratees (2012), http://johnlato.blogspot.com/2012/06/understandings-of-iteratees.html

  17. Oppen, D.C.: Prettyprinting. ACM Trans. Program. Lang. Syst. 2, 465–483 (1980)

    Article  Google Scholar 

  18. Chitil, O.: Pretty printing with lazy dequeues. ACM Trans. Program. Lang. Syst. 27, 163–184 (2005)

    Article  Google Scholar 

  19. Hughes, J.: The Design of a Pretty-Printing Library. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925, pp. 53–96. Springer, Heidelberg (1995)

    Chapter  Google Scholar 

  20. Wadler, P.: A prettier printer. In: The Fun of Programming. A Symposium in Honour of Professor Richard Bird’s 60th birthday, Oxford (2003)

    Google Scholar 

  21. Swierstra, S.D.: Linear, online, functional pretty printing (corrected and extended version). Technical Report UU-CS-2004-025a, Utrecht University (2004)

    Google Scholar 

  22. Dijkstra, A.: Stepping through Haskell. PhD thesis, Utrecht University, Department of Information and Computing Sciences (2005)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2012 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Kiselyov, O., Peyton-Jones, S., Sabry, A. (2012). Lazy v. Yield: Incremental, Linear Pretty-Printing. In: Jhala, R., Igarashi, A. (eds) Programming Languages and Systems. APLAS 2012. Lecture Notes in Computer Science, vol 7705. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-35182-2_14

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-35182-2_14

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-35181-5

  • Online ISBN: 978-3-642-35182-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics