Abstract

Iteratee IO is a style of incremental input processing with precise resource control. The style encourages building input processors from a user-extensible set of primitives by chaining, layering, pairing and other modes of compositions. The programmer is still able, where needed, to precisely control look-ahead, the allocation of buffers, file descriptors and other resources. The style is especially suitable for processing of communication streams, large amount of data, and data undergone several levels of encoding such as pickling, compression, chunking, framing. It has been used for programming high-performance (HTTP) servers and web frameworks, in computational linguistics and financial trading.

We exposit programming with iteratees, contrasting them with Lazy IO and the Handle-based, |stdio|-like IO. We relate them to online parser combinators. We introduce a simple implementation as free monads, which lets us formally reason with iteratees. As an example, we validate several equational laws and use them to optimize iteratee programs. The simple implementation helps understand existing implementations of iteratees and derive new ones.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Claessen, K.: Parallel parsing processes. Journal of Functional Programming 14(6), 741–757 (2004)MATHCrossRefGoogle Scholar
  2. 2.
    Collins, G.D.: snap-server: An iteratee-based http server library (2011), http://snapframework.com/docs/latest/snap-server/index.html
  3. 3.
    Harrison, W.L.: The Essence of Multitasking. In: Johnson, M., Vene, V. (eds.) AMAST 2006. LNCS, vol. 4019, pp. 158–172. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  4. 4.
    Hinze, R.: Deriving backtracking monad transformers. In: ICFP, pp. 186–197. ACM Press (2001)Google Scholar
  5. 5.
    Kiselyov, O.: Incremental multi-level input processing with left-fold enumerator: predictable, high-performance, safe, and elegant. In: ACM SIGPLAN 2008 Developer Tracks on Functional Programming (DEFUN 2008) (2008)Google Scholar
  6. 6.
    Lato, J.W.: Iteratee: Teaching an old fold new tricks. In: Yorgey, B. (ed.) The Monad.Reader, vol. 16, pp. 19–35 (2010)Google Scholar
  7. 7.
    Launchbury, J., Peyton Jones, S.L.: State in Haskell. Journal Lisp and Symbolic Computation 8(4), 293–341 (1995)CrossRefGoogle Scholar
  8. 8.
    Millikin, J.: Understanding iteratees (2010), http://john-millikin.com/articles/understanding-iteratees/
  9. 9.
    Parker, C.: Iteratees at Tsuru Capital (2011), http://blog.kfish.org/2011/09/iteratees-at-tsuru.html
  10. 10.
  11. 11.
    de Rauglaudre, D.: Camlp4 - Reference Manual, version 3.07 (2003), http://caml.inria.fr/pub/docs/manual-camlp4/
  12. 12.
    Shaw, M., Wulf, W.A., London, R.L.: Abstraction and verification in Alphard: defining and specifying iteration and generators. Communications of the ACM 20(8), 553–564 (1977)MATHCrossRefGoogle Scholar
  13. 13.
    Swierstra, S.D.: Combinator Parsing: A Short Tutorial. In: Bove, A., Barbosa, L.S., Pardo, A., Pinto, J.S. (eds.) LerNet ALFA Summer School 2008. LNCS, vol. 5520, pp. 252–300. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  14. 14.
    Swierstra, W.: Data types á la carte. Journal of Functional Programming 18(4), 423–436 (2008)MathSciNetMATHCrossRefGoogle Scholar
  15. 15.
    Tarau, P.: Fluents: A Refactoring of Prolog for Uniform Reflection and Interoperation with External Objects. In: Palamidessi, C., Moniz Pereira, L., Lloyd, J.W., Dahl, V., Furbach, U., Kerber, M., Lau, K.-K., Sagiv, Y., Stuckey, P.J. (eds.) CL 2000. LNCS (LNAI), vol. 1861, pp. 1225–1239. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  16. 16.
  17. 17.
    Yamamoto, K.: A tutorial on the enumerator library (2011), http://www.mew.org/~kazu/proj/enumerator/
  18. 18.
    Yang, E.Z.: Why iteratees are hard to understand (2012), http://blog.ezyang.com/2012/01/why-iteratees-are-hard-to-understand/

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Oleg Kiselyov

There are no affiliations available

Personalised recommendations