Hostname: page-component-848d4c4894-v5vhk Total loading time: 0 Render date: 2024-06-23T05:16:51.616Z Has data issue: false hasContentIssue false

A monadic framework for delimited continuations

Published online by Cambridge University Press:  01 November 2007

R. KENT Dyvbig
Affiliation:
Indiana University, IN, USA
SIMON PEYTON JONES
Affiliation:
Microsoft Research, Cambridge, USA
AMR SABRY
Affiliation:
Indiana University, IN, USA
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

Delimited continuations are more expressive than traditional abortive continuations and they apparently require a framework beyond traditional continuation-passing style (CPS). We show that this is not the case: standard CPS is sufficient to explain the common control operators for delimited continuations. We demonstrate this fact and present an implementation as a Scheme library. We then investigate a typed account of delimited continuations that makes explicit where control effects can occur. This results in a monadic framework for typed and encapsulated delimited continuations, which we design and implement as a Haskell library.

Type
Article
Copyright
Copyright © Cambridge University Press 2007

References

Ariola, Z. M., Herbelin, H. and Sabry, A. (2004) A type-theoretic foundation of continuations and prompts. Pages 40–53 of ACM SIGPLAN International Conference on Functional Programming. ACM Press, New York.Google Scholar
Biernacki, D. and Danvy, O. (2006) A simple proof of a folklore theorem about delimited control. J. Funct. Program, 16, 269280.Google Scholar
Cheney, J. and Hinze, R. (2002) A lightweight implementation of generics and dynamics. Pages 90–104 of: Proceedings of the ACM SIGPLAN Workshop on Haskell. New York: ACM Press.Google Scholar
Danvy, O. and Filinski, A. (1989) A functional abstraction of typed contexts. Tech. rept. 89/12. DIKU, University of Copenhagen, Copenhagen, Denmark.Google Scholar
Danvy, O. and Filinski, A. (1990) Abstracting control. Pages 151–160 of: Proceedings of the 1990 ACM Conference on LISP and Functional Programming. New York: ACM Press.Google Scholar
Dybvig, R. K. and Hieb, R. (1989) Engines from continuations. Computer Languages, 14 (2), 109123.Google Scholar
Felleisen, M., Friedman, D. P., Kohlbecker, E. and Duba, B. (1987a) A syntactic theory of sequential control. Theor. Comput. Sci. 52 (3), 205237.CrossRefGoogle Scholar
Felleisen, M. (1988) The theory and practice of first-class prompts. Pages 180–190 of: Conference Record of the ACM SIGPLAN-SIGACT Symposium on the Principles of Programming Languages. New York: ACM Press.Google Scholar
Felleisen, M. and Friedman, D. P. (1987) A reduction semantics for imperative higher-order languages. Parallel Architectures and Languages Europe, 259, 206223.Google Scholar
Felleisen, M., Friedman, D. P., Duba, B. and Merrill, J.. (1987b) Beyond continuations. Tech. rept. 216. Indiana University Computer Science Department.Google Scholar
Felleisen, M., Wand, M., Friedman, D. P. and Duba, B. F. (1988) Abstract continuations: A mathematical semantics for handling full functional jumps. Pages 52–62 of: Proceedings of the ACM Conference on Lisp and Functional Programming. New York: ACM Press.Google Scholar
Filinski, A. (1994) Representing monads. Pages 446–457 of: Conference Record of the ACM SIGPLAN-SIGACT Symposium on the Principles of Programming Languages. New York: ACM Press.Google Scholar
Filinski, A. (1996) Controlling effects. PhD thesis, School of Computer Science, Carnegie Mellon University. Technical Report CMU-CS-96-119.Google Scholar
Filinski, A. (1999) Representing layered monads. Pages 175–188 of: Conference Record of the ACM SIGPLAN-SIGACT Symposium on the Principles of Programming Languages. New York: ACM Press.Google Scholar
Findler, R. B., Latendresse, M. and Felleisen, M. (2001) Behavioral contracts and behavioral subtyping. Pages 229–236 of: ESEC/FSE-9: Proceedings of the 8th European Software Engineering Conference. New York, NY: ACM Press.Google Scholar
Friedman, D. P. and Kiselyov, O. (2005) A declarative applicative logic programming system. Available from: http://kanren.sourceforge.net/.Google Scholar
Gasbichler, M. and Sperber, M. (2002) Final shift for call/cc: direct implementation of shift and reset. Pages 271–282 of: ACM SIGPLAN International Conference on Functional Programming. ACM Press.Google Scholar
Gunter, C. A.Rémy, D. and Riecke, J. G. (1995) A generalization of exceptions and control in ML-like languages. Functional Programming & Computer Architecture. New York: ACM Press.Google Scholar
Harper, R., Duba, B. F. and MacQueen, D. (1993) Typing first-class continuations in ML. J. Funct. Program. 3 (4), 465484.Google Scholar
Hatcliff, J. and Danvy, O. (1994) A generic account of continuation-passing styles. Pages 458–471 of: Conference Record of the ACM SIGPLAN-SIGACT Symposium on the Principles of Programming Languages. New York: ACM Press.Google Scholar
Hieb, R. and Dybvig, R. K. (1990) Continuations and Concurrency. Pages 128–136 of: Symposium on Principles and Practice of Parallel Programming. SIGPLAN Notices, vol. 25 (3).Google Scholar
Hieb, R., Dybvig, R.K. and Bruggeman, C. (1990) Representing control in the presence of first-class continuations. Pages 66–77 of: Proceedings of the SIGPLAN '90 Conference on Programming Language Design and Implementation.CrossRefGoogle Scholar
Hieb, R., Dybvig, R. K. and Anderson, III, C. W. (1994) Subcontinuations. Lisp and Symbolic Computation, 7 (1), 83110.CrossRefGoogle Scholar
Hinze, R. (2000) Deriving backtracking monad transformers. Pages 186–197 of: ICFP '00: Proceedings of the 5th ACM SIGPLAN International Conference on Functional Programming. ACM Press.Google Scholar
Huet, G. (1997) The zipper. J. Funct. Program. 7 (5), 549554.CrossRefGoogle Scholar
Kiselyov, O. (2005) How to remove a dynamic prompt: static and dynamic delimited continuation operators are equally expressible. Tech. rept. TR611. Indiana University.Google Scholar
Kiselyov, O., Chung-chieh, Shan, Friedman, D. P. and Sabry, A. (2005) Backtracking, interleaving, and terminating monad transformers Functional Pearl. ACM SIGPLAN International Conference on Functional Programming. ACM Press, New York.Google Scholar
Launchbury, J. and Peyton Jones, S. L. (1995) State in Haskell. Lisp and Symbolic Computation, 8 (4), 293341.Google Scholar
Moggi, E. (1991) Notions of computation and monads. Infor. & Comput. 93 (1), 5592.CrossRefGoogle Scholar
Moreau, L. and Queinnec, C. (1994) Partial continuations as the difference of continuations. A duumvirate of control operators. Lecture Notes in Computer Science, 844.CrossRefGoogle Scholar
Murthy, C. (1992) Control operators, hierarchies, and pseudo-classical type systems: A-translation at work. Pages 49–71 of: ACM Workshop on Continuations.Google Scholar
Nanevski, A. (2004) A modal calculus for named control effects. Unpublished manuscript.Google Scholar
Pottier, F. and Régis-Gianas, Y. (2006) Stratified type inference for generalised algebraic data types. Pages 232–244 of: 33rd ACM Symposium on Principles of Programming Languages (POPL'06). ACM.Google Scholar
Queinnec, C. and Serpette, B. (1991) A dynamic extent control operator for partial continuations. Pages 174–184 of: Conference Record of the ACM SIGPLAN-SIGACT Symposium on the Principles of Programming Languages. New York: ACM Press.Google Scholar
Chung-chieh, Shan (2004) Shift to control. Pages 99–107 of: Shivers, O. and Waddell, O. (editors), Proceedings of the 5th Workshop on Scheme and Functional Programming. Technical report, Computer Science Department, Indiana University, 2004.Google Scholar
Sitaram, D. and Felleisen, M. (1990a) Control delimiters and their hierarchies. Lisp & Symbolic Computation, 3 (1), 6799.CrossRefGoogle Scholar
Sitaram, D. and Felleisen, M. (1990b) Reasoning with continuations II: full abstraction for models of control. Pages 161–175 of: LFP '90: Proceedings of the 1990 ACM Conference on Lisp and Functional Programming. New York, NY, USA: ACM Press.Google Scholar
Sitaram, D. and Felleisen, M. (1991) Models of continuations without continuations. Pages 185–196 of: POPL '91: Proceedings of the 18th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. New York, NY, USA: ACM Press.Google Scholar
Strachey, C. and Wadsworth, C. P. (1974) Continuations A mathematical semantics for handling full jumps. Technical Monograph PRG-11. Oxford University Computing Laboratory Programming Research Group.Google Scholar
Tang, A. (2005) Pugs: Boolstrapping Perl 6 with Haskell. Available from http://perlcabal.org/~autrijus/hw2005.pdf.Google Scholar
Thielecke, H. (2003) From control effects to typed continuation passing. Pages 139–149 of: Conference Record of the ACM SIGPLAN-SIGACT Symposium on the Principles of Programming Languages. ACM SIGPLAN Notices, vol. 38, 1.Google Scholar
Wadler, P. (1994) Monads and composable continuations. Lisp & Symbolic Computation, 7 (1), 3956.Google Scholar
Wadler, P. (1998) The marriage of effects and monads. Pages 63–74 of: ACM SIGPLAN International Conference on Functional Programming. ACM Press.Google Scholar
Xi, H., Chen, C. and Chen, G. (2003) Guarded recursive datatype constructors. Pages 224–235 of: Norris, C. and Fenwick, Jr., J. B. (editors), Conference Record of the ACM SIGPLAN-SIGACT Symposium on the Principles of Programming Languages. ACM SIGPLAN Notices, vol. 38, 1.CrossRefGoogle Scholar
Submit a response

Discussions

No Discussions have been published for this article.