Advertisement

Towards Deriving Type Systems and Implementations for Coroutines

  • Konrad Anton
  • Peter Thiemann
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6461)

Abstract

Starting from reduction semantics for several styles of coroutines from the literature, we apply Danvy’s method to obtain equivalent functional implementations (definitional interpreters) for them. By applying existing type systems for programs with continuations, we obtain sound type systems for coroutines through the translation. The resulting type systems are similar to earlier hand-crafted ones. As a side product, we obtain implementations for these styles of coroutines in OCaml.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Anton, K., Thiemann, P.: Typing coroutines. In: Page, R., Zsók, V., Horváth, Z. (eds.) Eleventh Symposium on Trends in Functional Programming (draft proceedings), pp. 91–105. University of Oklahoma Printing Services (2010)Google Scholar
  2. 2.
    Asai, K., Kameyama, Y.: Polymorphic delimited continuations. In: Shao, Z. (ed.) APLAS 2007. LNCS, vol. 4807, pp. 239–254. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  3. 3.
    Blazevic, M.: monad-coroutine: Coroutine monad transformer for suspending and resuming monadic computations (2010), http://hackage.haskell.org/package/monad-coroutine
  4. 4.
    Carette, J., Kiselyov, O., Chieh Shan, C.: Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. J. Funct. Program. 19(5), 509–543 (2009)MathSciNetCrossRefzbMATHGoogle Scholar
  5. 5.
    Conway, M.E.: Design of a separable transition-diagram compiler. ACM Comm. 6(7), 396–408 (1963)CrossRefzbMATHGoogle Scholar
  6. 6.
    Danvy, O.: Defunctionalized interpreters for programming languages, pp. 131–142 (2008)Google Scholar
  7. 7.
    Danvy, O., Filinski, A.: A functional abstraction of typed contexts. Technical Report 89/12, DIKU, University of Copenhagen (July 1989)Google Scholar
  8. 8.
    Danvy, O., Filinski, A.: Abstracting control. In: Proc. 1990 ACM Conference on Lisp and Functional Programming, Nice, France, pp. 151–160. ACM Press, New York (1990)CrossRefGoogle Scholar
  9. 9.
    Danvy, O., Millikin, K.: Refunctionalization at work. Science of Computer Programming 74(8), 534–549 (2009)MathSciNetCrossRefzbMATHGoogle Scholar
  10. 10.
    Danvy, O., Nielsen, L.R.: Refocusing in reduction semantics. Research Report BRICS RS-04-26, DAIMI, Department of Computer Science, University of Aarhus, Aarhus, Denmark (November 2004)Google Scholar
  11. 11.
    de Moura, A.L., Ierusalimschy, R.: Revisiting coroutines. ACM Trans. Program. Lang. Syst. 31(2), 1–31 (2009)CrossRefGoogle Scholar
  12. 12.
    de Moura, A.L., Rodriguez, N., Ierusalimschy, R.: Coroutines in Lua. Journal of Universal Computer Science 10, 925 (2004)Google Scholar
  13. 13.
    Friedman, D.P., Wand, M.: Essentials of Programming Languages, 3rd edn. MIT Press, McGraw-Hill (2008)Google Scholar
  14. 14.
    Haynes, C.T., Friedman, D.P., Wand, M.: Continuations and coroutines. In: ACM Conference on Lisp and Functional Programming, pp. 293–298 (1984)Google Scholar
  15. 15.
    Kiselyov, O.: Delimited control in OCaml, abstractly and concretely: System description. In: Blume, M., Kobayashi, N., Vidal, G. (eds.) FLOPS 2010. LNCS, vol. 6009, pp. 304–320. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  16. 16.
    Marlin, C.D.: Coroutines: a programming methodology, a language design and an implementation. Springer, Heidelberg (1980)CrossRefzbMATHGoogle Scholar
  17. 17.
    Microsoft Corp. C# Version 2.0 Specification (2005), http://msdn.microsoft.com/en-US/library/618ayhy6v=VS.80.aspx
  18. 18.
    Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)zbMATHGoogle Scholar
  19. 19.
    Thiemann, P.: Combinators for program generation. J. Funct. Program. 9(5), 483–525 (1999)MathSciNetCrossRefzbMATHGoogle Scholar
  20. 20.
    Van Rossum, G., Eby, P.: PEP 342 – coroutines via enhanced generators (2005), http://www.python.org/dev/peps/pep-0342/
  21. 21.
    Wirth, N.: Programming in Modula-2. Springer, Heidelberg (1982)CrossRefzbMATHGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Konrad Anton
    • 1
  • Peter Thiemann
    • 1
  1. 1.Institut für InformatikUniversität FreiburgGermany

Personalised recommendations