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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
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)
Asai, K., Kameyama, Y.: Polymorphic delimited continuations. In: Shao, Z. (ed.) APLAS 2007. LNCS, vol. 4807, pp. 239–254. Springer, Heidelberg (2007)
Blazevic, M.: monad-coroutine: Coroutine monad transformer for suspending and resuming monadic computations (2010), http://hackage.haskell.org/package/monad-coroutine
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)
Conway, M.E.: Design of a separable transition-diagram compiler. ACM Comm. 6(7), 396–408 (1963)
Danvy, O.: Defunctionalized interpreters for programming languages, pp. 131–142 (2008)
Danvy, O., Filinski, A.: A functional abstraction of typed contexts. Technical Report 89/12, DIKU, University of Copenhagen (July 1989)
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)
Danvy, O., Millikin, K.: Refunctionalization at work. Science of Computer Programming 74(8), 534–549 (2009)
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)
de Moura, A.L., Ierusalimschy, R.: Revisiting coroutines. ACM Trans. Program. Lang. Syst. 31(2), 1–31 (2009)
de Moura, A.L., Rodriguez, N., Ierusalimschy, R.: Coroutines in Lua. Journal of Universal Computer Science 10, 925 (2004)
Friedman, D.P., Wand, M.: Essentials of Programming Languages, 3rd edn. MIT Press, McGraw-Hill (2008)
Haynes, C.T., Friedman, D.P., Wand, M.: Continuations and coroutines. In: ACM Conference on Lisp and Functional Programming, pp. 293–298 (1984)
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)
Marlin, C.D.: Coroutines: a programming methodology, a language design and an implementation. Springer, Heidelberg (1980)
Microsoft Corp. C# Version 2.0 Specification (2005), http://msdn.microsoft.com/en-US/library/618ayhy6v=VS.80.aspx
Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)
Thiemann, P.: Combinators for program generation. J. Funct. Program. 9(5), 483–525 (1999)
Van Rossum, G., Eby, P.: PEP 342 – coroutines via enhanced generators (2005), http://www.python.org/dev/peps/pep-0342/
Wirth, N.: Programming in Modula-2. Springer, Heidelberg (1982)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2010 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Anton, K., Thiemann, P. (2010). Towards Deriving Type Systems and Implementations for Coroutines. In: Ueda, K. (eds) Programming Languages and Systems. APLAS 2010. Lecture Notes in Computer Science, vol 6461. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-17164-2_6
Download citation
DOI: https://doi.org/10.1007/978-3-642-17164-2_6
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-17163-5
Online ISBN: 978-3-642-17164-2
eBook Packages: Computer ScienceComputer Science (R0)