A monadic framework for delimited continuations

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.

[1]  Matthias Felleisen,et al.  Reasoning with continuations II: full abstraction for models of control , 1990, LISP and Functional Programming.

[2]  Olivier Danvy,et al.  A generic account of continuation-passing styles , 1994, POPL '94.

[3]  Michael Sperber,et al.  Final shift for call/cc:: direct implementation of shift and reset , 2002, ICFP '02.

[4]  Philip Wadler,et al.  The marriage of effects and monads , 1998, ICFP '98.

[5]  Olivier Danvy,et al.  Abstracting control , 1990, LISP and Functional Programming.

[6]  Andrzej Filinski,et al.  Representing layered monads , 1999, POPL '99.

[7]  O. Danvy,et al.  A Simple Proof of a Folklore Theorem about Delimited Control , 2005 .

[8]  Robert Harper,et al.  Typing first-class continuations in ML , 1991, POPL '91.

[9]  Olivier Danvy,et al.  A Functional Abstraction of Typed Contexts , 1989 .

[10]  Gang Chen,et al.  Guarded recursive datatype constructors , 2003, POPL '03.

[11]  Robert Hieb,et al.  Engines From Continuations , 1989, Comput. Lang..

[12]  Matthias Felleisen,et al.  A Syntactic Theory of Sequential Control , 1987, Theor. Comput. Sci..

[13]  James Cheney,et al.  A lightweight implementation of generics and dynamics , 2002, Haskell '02.

[14]  Andrzej Filinski,et al.  Representing monads , 1994, POPL '94.

[15]  Luc Moreau,et al.  Partial Continuations as the Difference of Continuations - A Duumvirate of Control Operators , 1994, PLILP.

[16]  Ralf Hinze,et al.  Deriving backtracking monad transformers , 2000, ICFP '00.

[17]  Gérard P. Huet,et al.  The Zipper , 1997, Journal of Functional Programming.

[18]  Matthias Felleisen,et al.  The theory and practice of first-class prompts , 1988, POPL '88.

[19]  Robert Hieb,et al.  Continuations and concurrency , 1990, PPOPP '90.

[20]  Simon L. Peyton Jones,et al.  State in Haskell , 1995, LISP Symb. Comput..

[21]  Matthias Felleisen,et al.  Models of continuations without continuations , 1991, POPL '91.

[22]  Amr Sabry,et al.  Backtracking, interleaving, and terminating monad transformers: (functional pearl) , 2005, ICFP '05.

[23]  Gregory F. Johnson,et al.  Stores and partial continuations as first-class objects in a language and its environment , 1988, POPL '88.

[24]  Didier Rémy,et al.  A generalization of exceptions and control in ML-like languages , 1995, FPCA '95.

[25]  Chung-chieh Shan,et al.  Shift control. , 2002, Nursing standard (Royal College of Nursing (Great Britain) : 1987).

[26]  Hayo Thielecke,et al.  From control effects to typed continuation passing , 2003, POPL '03.

[27]  Eugenio Moggi,et al.  Notions of Computation and Monads , 1991, Inf. Comput..

[28]  Philip Wadler,et al.  Monads and composable continuations , 1994, LISP Symb. Comput..

[29]  Christopher Strachey,et al.  Continuations: A Mathematical Semantics for Handling Full Jumps , 2000, High. Order Symb. Comput..

[30]  Matthias Felleisen,et al.  A Reduction Semantics for Imperative Higher-Order Languages , 1987, PARLE.

[31]  Amr Sabry,et al.  A type-theoretic foundation of continuations and prompts , 2004, ICFP '04.

[32]  Yann Régis-Gianas,et al.  Stratified type inference for generalized algebraic data types , 2006, POPL '06.

[33]  Martin Odersky,et al.  An Extension of ML with First-Class Abstract Types , 2009 .

[34]  Olivier Danvy,et al.  THEORETICAL PEARL: A simple proof of a folklore theorem about delimited control , 2005, Journal of Functional Programming.

[35]  Matthias Felleisen,et al.  Control delimiters and their hierarchies , 1990, LISP Symb. Comput..

[36]  Oleg Kiselyov,et al.  How to remove a dynamic prompt: static and dynamic delimited continuation operators are equally expressible , 2005 .

[37]  Matthias Felleisen,et al.  Abstract continuations: a mathematical semantics for handling full jumps , 1988, LISP and Functional Programming.

[38]  Robert Hieb,et al.  Representing control in the presence of first-class continuations , 1990, PLDI '90.

[39]  Aleksandar Nanevski A modal calculus for named control e-ects , 2004 .

[40]  Christian Queinnec,et al.  A dynamic extent control operator for partial continuations , 1991, POPL '91.