## From Control Effects to Typed Continuation Passing (2003)

Venue: | In 30th SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’03 |

Citations: | 19 - 2 self |

### BibTeX

@INPROCEEDINGS{Thielecke03fromcontrol,

author = {Hayo Thielecke},

title = {From Control Effects to Typed Continuation Passing},

booktitle = {In 30th SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’03},

year = {2003},

pages = {139--149},

publisher = {ACM Press}

}

### Years of Citing Articles

### OpenURL

### Abstract

First-class continuations are a powerful computational effect, allowing the programmer to express any form of jumping. Types and effect systems can be used to reason about continuations, both in the source language and in the target language of the continuation-passing transform. In this paper, we establish the connection between an effect system for first-class continuations and typed versions of continuationpassing style. A region in the effect system determines a local answer type for continuations, such that the continuation transforms of pure expressions are parametrically polymorphic in their answer types. We use this polymorphism to derive transforms that make use of effect information, in particular, a mixed linear/non-linear continuation-passing transform, in which expressions without control effects are passed their continuations linearly.

### Citations

924 |
Categories for the working mathematician
- Lane
- 1971
(Show Context)
Citation Context ... o) - o, where o is a fresh answer type, the equality MK K(M(Ax.x)) amounts to naturality in o, with M being a natural transformation from the covariant horn functor [A - (-)] to the identity functor =-=[18]-=-. [AK]sNaturality is one of the fundamental notions of being uniform in o:. However, the naturality square above is much too weak as an induction hypothesis, since it is not even clear what naturality... |

619 |
Compiling with continuations
- Appel
- 1992
(Show Context)
Citation Context ...The transformation of a program into continuation passing style (CPS) makes all control transfers, such as jumps or procedure calls, explicit. CPS can be used as an intermediate language in compiling =-=[2, 26]-=-. Moreover, CPS makes it easy to accommodate powerful control operators in the Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fe... |

604 |
The Definition of Standard ML (Revised
- Milner, Tofte, et al.
- 1997
(Show Context)
Citation Context ...dge [13, 14], adding the operator call/cc to the polymorphic A-calculus makes the type system unsound, unless the rules for polymorphism are restricted; the value restriction, as found in Standard ML =-=[20]-=-, avoids this unsoundness. We restrict the rules dealing with polymorphism in Figure I to apply only to values. As usual, values V comprise i-abstractions, variables and constants (in this case only c... |

589 | From System F to typed assembly language
- Morrisett, Walker, et al.
- 1999
(Show Context)
Citation Context ...her research is to move closer to the machine. The polymorphic and linear typing of CPS code could be used for deriving efficient representation of control in typed intermediate or assembly languages =-=[21, 1]-=-. Linear continuation passing could be used to eliminate dynamic checks in implementations using one-shot continuations [5]. Starting from the mixed linear/non-linear CPS transform, it should be possi... |

364 |
Types, abstraction and parametric polymorphism
- Reynolds
- 1983
(Show Context)
Citation Context ...ke (((Aso:)s(Aso:))sfrom Example 3.5. What we need is some more general notion of being "wellbehaved " in op that specializes to naturality whenever the effect can be masked. Relational para=-=metricity [24, 28]-=- provides such a notion. The property we are aiming for is, in essence, one of its basic instances, the Reynolds isomorphism (Vo:.(A - o:) - o:)sA (where o: is not free in A). 4.1 Some basics on param... |

330 | Theorems for Free - WADLER - 1989 |

238 | Polymorphic effect systems
- Lucassen, Gifford
- 1988
(Show Context)
Citation Context ...incorporated into the New Jersey dialect of Standard ML [9]. A further refinement of types is given by type and effect systems, as in the FX programming language, which superimposes a type and effect =-=[17]-=- discipline on a Scheme-like language. While this effect system was originally concerned with assignments, Gifford and Jouvelot [15] extended it to control effects. The output of the CPS transform is ... |

235 | A formulae-as-types notion of control
- Griffin
- 1990
(Show Context)
Citation Context ...evels at which types can play a role: the source and the target language of the CPS transform. Types for continuation operators in the source, such as call/cc in Scheme [16], were proposed by Griffin =-=[12]-=- and incorporated into the New Jersey dialect of Standard ML [9]. A further refinement of types is given by type and effect systems, as in the FX programming language, which superimposes a type and ef... |

148 |
The theory and practice of first-class prompts
- Felleisen
- 1988
(Show Context)
Citation Context ...), it can only discard Ax.x, with K still being applied to the answer. Hence naturality is a possible notion of purity. A different perspective is given by control delimiters. Specifically, Felleisen =-=[10] defines a-=- control delimiter, or "prompt", that passes the identity continuation and wraps the current continuation around the answer: Naturality of M can then be read as M being insensitive to the in... |

128 |
Rabbit: A compiler for Scheme
- Steele
- 1978
(Show Context)
Citation Context ...The transformation of a program into continuation passing style (CPS) makes all control transfers, such as jumps or procedure calls, explicit. CPS can be used as an intermediate language in compiling =-=[2, 26]-=-. Moreover, CPS makes it easy to accommodate powerful control operators in the Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fe... |

105 |
Danvy and Andrzej Filinski. Representing control: A study of the CPS transformation
- Olivier
- 1992
(Show Context)
Citation Context ...s2)s In particular, the type variable fi could itself be specialized to continuation type, giving us composable continuations in the style that Danvy and Filinski call meta-continuation passing style =-=[7]-=-. Using the answer type polymorphism, we can in fact switch to meta-continuation passing style locally, each time an effect is masked, as we do in our next CPS transform. Definition 4.4 The effect-bas... |

93 | Typing first-class continuations in ML
- Duba, Harper, et al.
- 1987
(Show Context)
Citation Context ...anguage of the CPS transform. Types for continuation operators in the source, such as call/cc in Scheme [16], were proposed by Griffin [12] and incorporated into the New Jersey dialect of Standard ML =-=[9]-=-. A further refinement of types is given by type and effect systems, as in the FX programming language, which superimposes a type and effect [17] discipline on a Scheme-like language. While this effec... |

74 | Parametric polymorphism and operational equivalence
- Pitts
- 2000
(Show Context)
Citation Context ...parametricity We recall some of the basics of parametricity [24] to prove what Wadler calls "theorems for free" [28]: equational properties that follow from the type of an expression. We fol=-=low Pitts [23]-=- in working directly on the syntax. We write R: AsAsif R is a relation between A and A . Let R: AsA' and R2: BsB' be relations. Then we define a relations-* 2: (A -* U) * (A' -* U') by (F, F') E R-->R... |

68 | Explicit polymorphism and CPS conversion
- Harper, Lillibridge
- 1993
(Show Context)
Citation Context ...tem (ca11/cc) Figure 2: Type and effect rule for call/cc and r k caii/cc: ((AsB) Z A)sA Here A and B can be any types; note in particular that A may contain p free. As shown by Harper and Lillibridge =-=[13, 14]-=-, adding the operator call/cc to the polymorphic A-calculus makes the type system unsound, unless the rules for polymorphism are restricted; the value restriction, as found in Standard ML [20], avoids... |

67 | Continuation semantics in typed lambda calculi (summary
- Meyer, Wand
- 1985
(Show Context)
Citation Context ...stem was originally concerned with assignments, Gifford and Jouvelot [15] extended it to control effects. The output of the CPS transform is highly stylized; some of this can be formalized with types =-=[19]-=-. Concretely, if an ex_pression M has type A, its CPS transform M has type (A - Ans) - Ans, where the latter typing can be refined in several ways (some of which are part of the continuations folklore... |

46 |
Implementation of the typed call-by-value lambda-calculus using a stack of regions
- Tofte, Talpin
- 1994
(Show Context)
Citation Context ...(In fact, even if the source language had no polymorphism, we would still have answer type polymorphism in the target of the CPS transform.) Banerjee, Heintze and Riecke [3] encode Tofte and Talpin's =-=[27]-=- region calculus into a polymorphic A-calculus. It remains to be seen whether their approach could be combined with the one presented here. 6.2 Directions for further work We have considered only a ve... |

45 | Representing control in the presence of one-shot continuations
- Bruggeman, Waddell, et al.
- 1996
(Show Context)
Citation Context ...nt representation of control in typed intermediate or assembly languages [21, 1]. Linear continuation passing could be used to eliminate dynamic checks in implementations using one-shot continuations =-=[5]-=-. Starting from the mixed linear/non-linear CPS transform, it should be possible to derive an implementation in which the continuations of expressions without control effects are stack allocated [6], ... |

35 | Polymorphic type assignment and CPS conversion
- Harper, Lillibridge
- 1993
(Show Context)
Citation Context ...tem (ca11/cc) Figure 2: Type and effect rule for call/cc and r k caii/cc: ((AsB) Z A)sA Here A and B can be any types; note in particular that A may contain p free. As shown by Harper and Lillibridge =-=[13, 14]-=-, adding the operator call/cc to the polymorphic A-calculus makes the type system unsound, unless the rules for polymorphism are restricted; the value restriction, as found in Standard ML [20], avoids... |

28 | Region analysis and the polymorphic lambda calculus
- Banerjee, Heintze, et al.
- 1999
(Show Context)
Citation Context ...ansform, as we consider here. (In fact, even if the source language had no polymorphism, we would still have answer type polymorphism in the target of the CPS transform.) Banerjee, Heintze and Riecke =-=[3]-=- encode Tofte and Talpin's [27] region calculus into a polymorphic A-calculus. It remains to be seen whether their approach could be combined with the one presented here. 6.2 Directions for further wo... |

25 | A first-order one-pass CPS transformation
- Danvy, Nielsen
- 2003
(Show Context)
Citation Context ...control operators [7]. We have not considered the issue of administrative reductions, but it would be straightforward to modify the transform in the light of Danvy and Nielsen's one-pass PS transform =-=[8]-=- to avoid generating administrative redexes, which could be done by adding subclauses for values in applications. Proposition 4.5 If F h M: A ! p then Fs[[]]: (7-. o) -. o If F h M: A ! 0 then Ps[[M]]... |

25 | Reasoning about Continuations with Control E ects
- Jouvelot, ord, et al.
- 1989
(Show Context)
Citation Context ...n the FX programming language, which superimposes a type and effect [17] discipline on a Scheme-like language. While this effect system was originally concerned with assignments, Gifford and Jouvelot =-=[15]-=- extended it to control effects. The output of the CPS transform is highly stylized; some of this can be formalized with types [19]. Concretely, if an ex_pression M has type A, its CPS transform M has... |

22 | The logical approach to stack typing
- Ahmed, Walker
- 2003
(Show Context)
Citation Context ...her research is to move closer to the machine. The polymorphic and linear typing of CPS code could be used for deriving efficient representation of control in typed intermediate or assembly languages =-=[21, 1]-=-. Linear continuation passing could be used to eliminate dynamic checks in implementations using one-shot continuations [5]. Starting from the mixed linear/non-linear CPS transform, it should be possi... |

21 | Formalizing Implementation Strategies for first-class Continuations
- Danvy
- 2000
(Show Context)
Citation Context ...s [5]. Starting from the mixed linear/non-linear CPS transform, it should be possible to derive an implementation in which the continuations of expressions without control effects are stack allocated =-=[6]-=-, while the continuations of expressions with control effects are allocated in a stack of regions [27]. Acknowledgments Thanks to Josh Berdine for discussions, and to the anonymous referees and Hongse... |

12 | Varieties of effects - Führmann - 2002 |

11 |
A selective cps transformation
- Nielsen
(Show Context)
Citation Context ...our earlier work on linear continuation passing [4]. Control delimiters, as studied by Felleisen [10] and Danvy and Filinski [7] have a similar aim of confining control to parts of a program. Nielsen =-=[22]-=- has recently defined a selective CPS transform that leaves expressions without control effects in direct style. His effect system, however, contains neither regions nor effect masking. Harper and Lil... |

8 |
and Hayo Thielecke. Typed exceptions and continuations cannot macro-express each other
- Riecke
- 1999
(Show Context)
Citation Context ...t, in that we can assume it to be a free type variable o: F I- M : ( A- o ) - o Relatively little use seems to have been made of the abstractness of the answer type, although it is used in a proof in =-=[25]-=-. Furthermore, if there are no control operators, then we can in fact V-quantify over the answer type variable: F - M: Vo.(A- o) -o 1.2 Naturality Another, a priori quite different, property which an ... |

7 |
Uday Reddy, and Hayo Thielecke. Linear continuation passing
- Berdine, O’Hearn
- 2002
(Show Context)
Citation Context ...oke it multiple times. Linear continuation passing is not restricted to languages without control: surprisingly many idioms of control, in which continuations are not first-class, adhere to linearity =-=[4]-=-. In the absence of control operators, local answer type polymorphism, naturality and linearity are all easy to see and to prove with a straightforward induction. The addition of call/cc to the source... |

1 |
Varieties of effects
- Ftihrmann
- 2002
(Show Context)
Citation Context ...nsforms from simpler ones. In particular, instantiating the answer type to fiso gives us a form of continuation-passing, state-passing transform. (The same observation has also been used by Ffihrmann =-=[11]-=- to generalize from a continuations monad to a state and continuations monad.) Since the state is merely passed along and not used for anything, it can be typed polymorphically. We do not need to chan... |

1 |
Theorems for free
- Wadlet
- 1989
(Show Context)
Citation Context ...ke (((Aso:)s(Aso:))sfrom Example 3.5. What we need is some more general notion of being "wellbehaved " in op that specializes to naturality whenever the effect can be masked. Relational para=-=metricity [24, 28]-=- provides such a notion. The property we are aiming for is, in essence, one of its basic instances, the Reynolds isomorphism (Vo:.(A - o:) - o:)sA (where o: is not free in A). 4.1 Some basics on param... |