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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Hughes, J.: Why functional programming matters. Comput. J. 32, 98–107 (1989)
McIlroy, M.D.: Power series, power serious. J. Funct. Program. 9, 325–337 (1999)
Bird, R.S.: Using circular programs to eliminate multiple traversals of data. Acta Informatica 21, 239–250 (1984), doi:10.1007/BF00264249
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)
Henderson, P., Morris Jr., J.H.: A lazy evaluator. In: POPL, pp. 95–103. ACM, New York (1976)
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)
Garcia, R., Lumsdaine, A., Sabry, A.: Lazy evaluation and delimited control. In: POPL, pp. 153–164. ACM, New York (2009)
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)
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)
Jackson, M.A.: Principles of Program Design. Academic Press, Inc., Orlando (1975)
James, R.P., Sabry, A.: Yield: Mainstream deliminted continuations. In: Theory and Practice of Delimited Continuations (2011)
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)
Kiselyov, O.: Iteratees. In: Schrijvers, T., Thiemann, P. (eds.) FLOPS 2012. LNCS, vol. 7294, pp. 166–181. Springer, Heidelberg (2012)
Liskov, B.: A history of CLU. Technical Report 561, MIT LCS (1992)
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)
Lato, J.W.: Understandings of iteratees (2012), http://johnlato.blogspot.com/2012/06/understandings-of-iteratees.html
Oppen, D.C.: Prettyprinting. ACM Trans. Program. Lang. Syst. 2, 465–483 (1980)
Chitil, O.: Pretty printing with lazy dequeues. ACM Trans. Program. Lang. Syst. 27, 163–184 (2005)
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)
Wadler, P.: A prettier printer. In: The Fun of Programming. A Symposium in Honour of Professor Richard Bird’s 60th birthday, Oxford (2003)
Swierstra, S.D.: Linear, online, functional pretty printing (corrected and extended version). Technical Report UU-CS-2004-025a, Utrecht University (2004)
Dijkstra, A.: Stepping through Haskell. PhD thesis, Utrecht University, Department of Information and Computing Sciences (2005)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)