Faster Coroutine Pipelines: A Reconstruction

  • Ruben P. PietersEmail author
  • Tom Schrijvers
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 11372)


Spivey has recently presented a novel functional representation that supports the efficient composition, or merging, of coroutine pipelines for processing streams of data. This representation was inspired by Shivers and Might’s three-continuation approach and is shown to be equivalent to a simple yet inefficient executable specification. Unfortunately, neither Shivers and Might’s original work nor the equivalence proof sheds much light on the underlying principles allowing the derivation of this efficient representation from its specification.

This paper gives the missing insight by reconstructing a systematic derivation in terms of known transformation steps from the simple specification to the efficient representation. This derivation sheds light on the limitations of the representation and on its applicability to other settings. In particular, it has enabled us to obtain a similar representation for pipes featuring two-way communication, similar to the Haskell pipes library. Our benchmarks confirm that this two-way representation retains the same improved performance characteristics.


Stream processing Structured recursion Algebra 



We would like to thank Nicolas Wu, Alexander Vandenbroucke and the anonymous PADL reviewers for their feedback. This work was partly funded by the Flemish Fund for Scientific Research (FWO).


  1. 1.
    Böhm, C., Berarducci, A.: Automatic synthesis of typed lambda-programs on term algebras. Theor. Comput. Sci. 39, 135–154 (1985). Scholar
  2. 2.
    Church, A.: The Calculi of Lambda-Conversion. Princeton University Press, Princeton (1941)zbMATHGoogle Scholar
  3. 3.
    Claessen, K.: Parallel parsing processes. J. Funct. Program. 14(6), 741–757 (2004). Scholar
  4. 4.
    Ghani, N., Uustalu, T., Vene, V.: Build, augment and destroy, universally. In: Chin, W.-N. (ed.) APLAS 2004. LNCS, vol. 3302, pp. 327–347. Springer, Heidelberg (2004). Scholar
  5. 5.
    Gonzalez, G.: Haskell Pipes library (2012).
  6. 6.
    Kammar, O., Lindley, S., Oury, N.: Handlers in action. In: Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming, ICFP 2013, pp. 145–158. ACM, New York (2013)
  7. 7.
    Lindley, S., McBride, C., McLaughlin, C.: Do be do be do. In: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, pp. 500–514. ACM, New York (2017).
  8. 8.
    Mogensen, T.: Efficient self-interpretation in lambda calculus. J. Funct. Program. 2(3), 345–364 (1992). Scholar
  9. 9.
    O’Sullivan, B.: Haskell Criterion library (2009).
  10. 10.
    Shivers, O., Might, M.: Continuations and transducer composition. In: Proceedings of the 27th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2006, pp. 295–307. ACM, New York (2006).
  11. 11.
    Snoyman, M.: Haskell Conduit library (2011).
  12. 12.
    Spivey, M.: Faster coroutine pipelines. In: Proceedings of the ACM Programming Languages, 1(ICFP), 5:1–5:23, August 2017. Scholar

Copyright information

© Springer Nature Switzerland AG 2019

Authors and Affiliations

  1. 1.KU LeuvenLeuvenBelgium

Personalised recommendations