## A Substructural Type System for Delimited Continuations

Citations: | 3 - 0 self |

### BibTeX

@MISC{Kiselyov_asubstructural,

author = {Oleg Kiselyov and Chung-chieh Shan},

title = {A Substructural Type System for Delimited Continuations },

year = {}

}

### OpenURL

### Abstract

We propose type systems that abstractly interpret small-step rather than big-step operational semantics. We treat an expression or evaluation context as a structure in a linear logic with hypothetical reasoning. Evaluation order is not only regulated by familiar focusing rules in the operational semantics, but also expressed by structural rules in the type system, so the types track control flow more closely. Binding and evaluation contexts are related, but the latter are linear. We use these ideas to build a type system for delimited continuations. It lets control operators change the answer type or act beyond the nearest dynamically-enclosing delimiter, yet needs no extra fields in judgments and arrow types to record answer types. The typing derivation of a directstyle program desugars it into continuation-passing style.

### Citations

1945 |
Abstract Interpretation: A Unified Lattice Model for Static Analysis of Programs by Construction or Approximation of Fixpoints
- Cousot, Cousot
- 1977
(Show Context)
Citation Context ...needs no extra fields in judgments and arrow types to record answer types. The typing derivation of a directstyle program desugars it into continuation-passing style. 1 Introduction Cousot and Cousot =-=[14]-=- originally presented abstract interpretation by starting with a small-step operational semantics. Nevertheless, the typical type system abstractly interprets [13] a denotational or big-step operation... |

469 |
The mathematics of sentence structure
- Lambek
- 1958
(Show Context)
Citation Context ...ary (#), and one unary (the implicit coercion from a value to a term). This logic is thus a restricted multimodal type-logical grammar (TLG). Multimodal TLG is a generalization of the Lambek calculus =-=[46]-=- whose proof theory and Kripke semantics are well-studied and well-behaved: there are sound and complete natural-deduction and sequent calculi with cut elimination [49, 52]. Our statements, terms, and... |

245 | A formulae-as-types notion of control
- Griffin
- 1990
(Show Context)
Citation Context ...ystems attach answer types to judgments and arrows as effect annotations [32, 34, 48, 61–63, 65]. These annotations obscure any logical interpretation of the types via the Curry-Howard correspondence =-=[4, 36, 42]-=-. For example, Danvy and Filinski [17] uses typing judgments of the form ρ, α ⊢ E : τ, β, where ρ is a typing environment, α and β are answer types, E is a term, and τ is its type. If E changes the an... |

208 | Continuation-based partial evaluation
- Lawall, Danvy
- 1994
(Show Context)
Citation Context ... value. This ability is useful in backtracking search [12, 18, 44, 59], direct-style representations of monads [30–32], the continuation-passing-style (CPS) transformation [17–19], partial evaluation =-=[6, 7, 10, 16, 23, 33, 37, 47, 64]-=-, Web interactions [35, 53], mobile code [50, 56, 60], and linguistics [9, 58]. ⋆ Thanks to Olivier Danvy, Andrzej Filinski, Michael Stone, Philip Wadler, and the anonymous referees. The appendices to... |

201 | Types as Abstract Interpretations
- Cousot
- 1997
(Show Context)
Citation Context ...le. 1 Introduction Cousot and Cousot [14] originally presented abstract interpretation by starting with a small-step operational semantics. Nevertheless, the typical type system abstractly interprets =-=[13]-=- a denotational or big-step operational semantics, in that each typing rule is the abstract interpretation of a denotational equation or a big-step evaluation judgment. Besides simplicity, one reason ... |

165 | Duality of computation
- Curien, Herbelin
- 2000
(Show Context)
Citation Context ...valuation order and control flow: the typing derivation of a direct-style term is essentially its CPS transformation. Our work exhibits a duality closely related to that for undelimited continuations =-=[15, 29, 55, 66]-=-, but investigating the delimited case remains future work.sGiven our analogy between small-step type-checking and small-step evaluation, we should relate our proof and term normalizations. It remains... |

141 | An Introduction to Substructural Logics
- Restall
- 2000
(Show Context)
Citation Context ...ms). It allows no exchange, associativity, weakening, or contraction except by the structural (5)srules in (5). It builds structures from values using six multiplicative-conjunctive punctuation marks =-=[54]-=-, or modes: four binary (juxtaposition and $ , ;), one nullary (#), and one unary (the implicit coercion from a value to a term). This logic is thus a restricted multimodal type-logical grammar (TLG).... |

95 | The zipper
- Huet
- 1997
(Show Context)
Citation Context ..., #). A statement, of the form C $ E (pronounced “plug”), represents the term E plugged into the coterm C. It is a state of the CK machine [25, 27, 28]. A statement can also be understood as a zipper =-=[41]-=- over a term. Among the binary constructors, $ has the lowest precedence, and juxtaposition (for function application) the highest. All binary constructors associate to the right, except juxtaposition... |

95 | The marriage of effects and monads - Wadler, Thiemann |

87 | Integrating functional and imperative programming - Gifford, Lucassen - 1986 |

74 | The Mystery of the Tower Revealed: A Non-Reflective Description of the Re lective Tower
- Wand, Friedman
- 1984
(Show Context)
Citation Context ...reas the second rule substitutes an argument coterm C into the body E in ξ0k. E. Both rules operate inside a term context C1 $ · · · $ Cn $ [ ], where n ≥ 0. This term context is the metacontinuation =-=[67]-=- that appears in CPS semantics [17–19] and abstract machines [11, 24] for delimited control. As in Sect. 3.1, the term equality rules in Fig. 3 are equations in the multisorted algebra of terms and co... |

69 | A functional correspondence between evaluators and abstract machines - Ager, Biernacki, et al. - 2003 |

66 | A functional abstraction of typed contexts
- Danvy, Filinski
- 1989
(Show Context)
Citation Context ...er type: to create functions [18], to find list prefixes [10], to represent parameterized monads [5], and to analyze questions and polarity in natural language [58]. These uses motivate a type system =-=[17]-=- that is sensitive to evaluation order. Unfortunately, no existing type system for delimited control subsumes all others, so no clear choice emerges for practical use. Moreover, the existing type syst... |

62 | A generalization of exceptions and control in ML-like languages
- Gunter, Rémy, et al.
- 1995
(Show Context)
Citation Context ...to combine multiple monadic effects [18, 31, 32], to normalize λ-terms with sums [7], and to simulate exceptions and mutable references [39] and dynamic binding [45]. These uses motivate type systems =-=[38, 39, 51]-=- that maintain a stack or heap of answer types. On the other hand, it is also useful for an expression to change the answer type, that is, to capture one delimited continuation then install another wi... |

58 | Types and effects, towards an integration of functional and imperative programming - Lucassen - 1987 |

57 | V.: Acute: High-level programming language design for distributed computation
- Sewell, Leifer, et al.
- 2007
(Show Context)
Citation Context ...ect-style representations of monads [30–32], the continuation-passing-style (CPS) transformation [17–19], partial evaluation [6, 7, 10, 16, 23, 33, 37, 47, 64], Web interactions [35, 53], mobile code =-=[50, 56, 60]-=-, and linguistics [9, 58]. ⋆ Thanks to Olivier Danvy, Andrzej Filinski, Michael Stone, Philip Wadler, and the anonymous referees. The appendices to this paper are online at http://okmij.org/ ftp/paper... |

49 | Continuations and concurrency - Hieb, Dybvig - 1990 |

40 |
The calculi of λv-CS conversion: A syntactic theory of control and state in imperative higherorder programming languages
- Felleisen
- 1987
(Show Context)
Citation Context ... easier to specify and reason with a small-step semantics (especially evaluation contexts) [68]. A canonical effect that makes semantics and types harder to determine inductively is delimited control =-=[25, 26]-=-. With this effect, an expression may access its delimited continuation [17–19] or delimited evaluation context as a first-class value. This ability is useful in backtracking search [12, 18, 44, 59], ... |

40 |
Declarative continuations: an investigation of duality in programming language semantics (lecture notes in computer science 389
- Filinski
- 1989
(Show Context)
Citation Context ...valuation order and control flow: the typing derivation of a direct-style term is essentially its CPS transformation. Our work exhibits a duality closely related to that for undelimited continuations =-=[15, 29, 55, 66]-=-, but investigating the delimited case remains future work.sGiven our analogy between small-step type-checking and small-step evaluation, we should relate our proof and term normalizations. It remains... |

39 | Parameterised notions of computation
- Atkey
(Show Context)
Citation Context ... answer type, that is, to capture one delimited continuation then install another with a different answer type: to create functions [18], to find list prefixes [10], to represent parameterized monads =-=[5]-=-, and to analyze questions and polarity in natural language [58]. These uses motivate a type system [17] that is sensitive to evaluation order. Unfortunately, no existing type system for delimited con... |

38 | Tridirectional typechecking
- Dunfield, Pfenning
- 2004
(Show Context)
Citation Context ... the cotype S in order to yield an answer of type T . Our approach to “visit subterms in evaluation position before the context in which they occur” may be an instance of tridirectional type-checking =-=[22]-=-. The 4th–6th rules for C〈?〉 ¢ E ⇒ ˆ T and the 2nd–4th rules for ˆ S ⇐ C〈〉 ¢ E : T are focusing rules: they traverse the applicative structure of E to find the next subterm to abstractly interpret acc... |

36 | Web interactions
- Graunke
- 2003
(Show Context)
Citation Context ... [12, 18, 44, 59], direct-style representations of monads [30–32], the continuation-passing-style (CPS) transformation [17–19], partial evaluation [6, 7, 10, 16, 23, 33, 37, 47, 64], Web interactions =-=[35, 53]-=-, mobile code [50, 56, 60], and linguistics [9, 58]. ⋆ Thanks to Olivier Danvy, Andrzej Filinski, Michael Stone, Philip Wadler, and the anonymous referees. The appendices to this paper are online at h... |

36 | Ordered Linear Logic and Applications
- Polakow
(Show Context)
Citation Context ...lization of the Lambek calculus [46] whose proof theory and Kripke semantics are well-studied and well-behaved: there are sound and complete natural-deduction and sequent calculi with cut elimination =-=[49, 52]-=-. Our statements, terms, and coterms (to the left of the turnstile) are TLG structures, restricted to be sort-correct. Our types and cotypes (to the right of the turnstile) are TLG formulae, restricte... |

34 | A functional correspondence between call-by-need evaluators and lazy abstract machines - Ager, Danvy, et al. - 2004 |

31 |
Extensional normalisation and type-directed partial evaluation for typed lambda calculus with sums
- Balat, Cosmo, et al.
- 2004
(Show Context)
Citation Context ... value. This ability is useful in backtracking search [12, 18, 44, 59], direct-style representations of monads [30–32], the continuation-passing-style (CPS) transformation [17–19], partial evaluation =-=[6, 7, 10, 16, 23, 33, 37, 47, 64]-=-, Web interactions [35, 53], mobile code [50, 56, 60], and linguistics [9, 58]. ⋆ Thanks to Olivier Danvy, Andrzej Filinski, Michael Stone, Philip Wadler, and the anonymous referees. The appendices to... |

31 | Delimited dynamic binding
- Kiselyov, Shan, et al.
(Show Context)
Citation Context ...earest dynamicallyenclosing delimiter: to combine multiple monadic effects [18, 31, 32], to normalize λ-terms with sums [7], and to simulate exceptions and mutable references [39] and dynamic binding =-=[45]-=-. These uses motivate type systems [38, 39, 51] that maintain a stack or heap of answer types. On the other hand, it is also useful for an expression to change the answer type, that is, to capture one... |

26 |
Control Operators, Hierarchies, and Pseudo-Classical Type Systems: A-Translation at Work
- Murthy
- 1992
(Show Context)
Citation Context ...to combine multiple monadic effects [18, 31, 32], to normalize λ-terms with sums [7], and to simulate exceptions and mutable references [39] and dynamic binding [45]. These uses motivate type systems =-=[38, 39, 51]-=- that maintain a stack or heap of answer types. On the other hand, it is also useful for an expression to change the answer type, that is, to capture one delimited continuation then install another wi... |

24 |
A type-theoretic foundation of continuations and prompts
- Ariola, Herbelin, et al.
- 2004
(Show Context)
Citation Context ...ystems attach answer types to judgments and arrows as effect annotations [32, 34, 48, 61–63, 65]. These annotations obscure any logical interpretation of the types via the Curry-Howard correspondence =-=[4, 36, 42]-=-. For example, Danvy and Filinski [17] uses typing judgments of the form ρ, α ⊢ E : τ, β, where ρ is a typing environment, α and β are answer types, E is a term, and τ is its type. If E changes the an... |

24 | Shift to control
- Shan
- 2004
(Show Context)
Citation Context ...e variation in their Appendix C [17], which we pronounce “shift-zero”. In the untyped setting, ξ0, shift, control [25, 26], and their variants [38–40] are all macro-expressible in terms of each other =-=[43, 57]-=-. In the typed setting, ξ0 easily emulates shift [17] (shift k. E translates to ξ0k. # $ E), but it remains to relate ξ0 to other type systems of control. In particular, unlike Gunter et al.’s system ... |

21 |
Combinators for program generation
- Thiemann
- 1999
(Show Context)
Citation Context ... value. This ability is useful in backtracking search [12, 18, 44, 59], direct-style representations of monads [30–32], the continuation-passing-style (CPS) transformation [17–19], partial evaluation =-=[6, 7, 10, 16, 23, 33, 37, 47, 64]-=-, Web interactions [35, 53], mobile code [50, 56, 60], and linguistics [9, 58]. ⋆ Thanks to Olivier Danvy, Andrzej Filinski, Michael Stone, Philip Wadler, and the anonymous referees. The appendices to... |

19 | An operational foundation for delimited continuations
- Biernacka, Biernacki, et al.
- 2005
(Show Context)
Citation Context |

19 | From interpreter to logic engine by defunctionalization
- Biernacki, Danvy
- 2003
(Show Context)
Citation Context ...d control [25, 26]. With this effect, an expression may access its delimited continuation [17–19] or delimited evaluation context as a first-class value. This ability is useful in backtracking search =-=[12, 18, 44, 59]-=-, direct-style representations of monads [30–32], the continuation-passing-style (CPS) transformation [17–19], partial evaluation [6, 7, 10, 16, 23, 33, 37, 47, 64], Web interactions [35, 53], mobile ... |

19 | Handling control
- Sitaram
- 1993
(Show Context)
Citation Context ...d control [25, 26]. With this effect, an expression may access its delimited continuation [17–19] or delimited evaluation context as a first-class value. This ability is useful in backtracking search =-=[12, 18, 44, 59]-=-, direct-style representations of monads [30–32], the continuation-passing-style (CPS) transformation [17–19], partial evaluation [6, 7, 10, 16, 23, 33, 37, 47, 64], Web interactions [35, 53], mobile ... |

18 | A syntactic correspondence between context-sensitive calculi and abstract machines
- Biernacka, Danvy
- 2007
(Show Context)
Citation Context ...dy E in ξ0k. E. Both rules operate inside a term context C1 $ · · · $ Cn $ [ ], where n ≥ 0. This term context is the metacontinuation [67] that appears in CPS semantics [17–19] and abstract machines =-=[11, 24]-=- for delimited control. As in Sect. 3.1, the term equality rules in Fig. 3 are equations in the multisorted algebra of terms and coterms as well as the reversible typing rules E ′ [C $ F E] : T ======... |

16 |
How to remove a dynamic prompt: static and dynamic delimited continuation operators are equally expressible
- Kiselyov
- 2005
(Show Context)
Citation Context ...e variation in their Appendix C [17], which we pronounce “shift-zero”. In the untyped setting, ξ0, shift, control [25, 26], and their variants [38–40] are all macro-expressible in terms of each other =-=[43, 57]-=-. In the typed setting, ξ0 easily emulates shift [17] (shift k. E translates to ξ0k. # $ E), but it remains to relate ξ0 to other type systems of control. In particular, unlike Gunter et al.’s system ... |

16 |
Categorial Type Logics, Handbook of Logic and Language
- Moortgat
- 1997
(Show Context)
Citation Context ...lization of the Lambek calculus [46] whose proof theory and Kripke semantics are well-studied and well-behaved: there are sound and complete natural-deduction and sequent calculi with cut elimination =-=[49, 52]-=-. Our statements, terms, and coterms (to the left of the turnstile) are TLG structures, restricted to be sort-correct. Our types and cotypes (to the right of the turnstile) are TLG formulae, restricte... |

15 | 2002. Memoization in type-directed partial evaluation
- Balat, Danvy
(Show Context)
Citation Context |

13 | A monadic framework for delimited continuations
- Dybvig, Peyton-Jones, et al.
- 2007
(Show Context)
Citation Context ...dy E in ξ0k. E. Both rules operate inside a term context C1 $ · · · $ Cn $ [ ], where n ≥ 0. This term context is the metacontinuation [67] that appears in CPS semantics [17–19] and abstract machines =-=[11, 24]-=- for delimited control. As in Sect. 3.1, the term equality rules in Fig. 3 are equations in the multisorted algebra of terms and coterms as well as the reversible typing rules E ′ [C $ F E] : T ======... |

12 |
2007, ‘Direct Compositionality on Demand
- Barker
(Show Context)
Citation Context ...sult of inc. Proposition 3 (Preservation). If E[E1] : T and E1 � E2 then E[E2] : T . We sketch the proof by stating three lemmas. The first lemma is termed direct compositionality on demand by Barker =-=[8]-=-: a subterm of a typed term is typed. Lemma 1. If E[E1] : T , then there exists some type T1 such that E1 : T1 and whenever E ′ 1 : T1 we have E[E ′ 1] : T . The two remaining lemmas are less trivial ... |

12 | Types as graphs: Continuations in type logical grammar
- Barker, Shan
- 2006
(Show Context)
Citation Context ...onads [30–32], the continuation-passing-style (CPS) transformation [17–19], partial evaluation [6, 7, 10, 16, 23, 33, 37, 47, 64], Web interactions [35, 53], mobile code [50, 56, 60], and linguistics =-=[9, 58]-=-. ⋆ Thanks to Olivier Danvy, Andrzej Filinski, Michael Stone, Philip Wadler, and the anonymous referees. The appendices to this paper are online at http://okmij.org/ ftp/papers/delim-control-logic.pdf... |

10 | An implementation of transparent migration on standard Scheme
- Sumii
- 2000
(Show Context)
Citation Context ...ect-style representations of monads [30–32], the continuation-passing-style (CPS) transformation [17–19], partial evaluation [6, 7, 10, 16, 23, 33, 37, 47, 64], Web interactions [35, 53], mobile code =-=[50, 56, 60]-=-, and linguistics [9, 58]. ⋆ Thanks to Olivier Danvy, Andrzej Filinski, Michael Stone, Philip Wadler, and the anonymous referees. The appendices to this paper are online at http://okmij.org/ ftp/paper... |

9 | The second Futamura projection for type-directed partial evaluation
- Grobauer, Yang
(Show Context)
Citation Context |

9 | Distribed control flow with classical modal logic (technical report
- Murphy, Crary, et al.
- 2004
(Show Context)
Citation Context ...ect-style representations of monads [30–32], the continuation-passing-style (CPS) transformation [17–19], partial evaluation [6, 7, 10, 16, 23, 33, 37, 47, 64], Web interactions [35, 53], mobile code =-=[50, 56, 60]-=-, and linguistics [9, 58]. ⋆ Thanks to Olivier Danvy, Andrzej Filinski, Michael Stone, Philip Wadler, and the anonymous referees. The appendices to this paper are online at http://okmij.org/ ftp/paper... |

8 | Syntactic theories in practice, in
- Danvy, Nielsen
(Show Context)
Citation Context ...s to the left. 3.1 A substructural logic for expressions and evaluation contexts Two statement equality rules enforce left-to-right, call-by-value evaluation, as evaluation contexts [25] and focusing =-=[20]-=- do in other accounts. Formally, our equality rules are equations in the multisorted algebra of statements, terms, and coterms, as well as the following reversible typing rules. C $ F E : T ========= ... |

8 |
terminating monad transformers: (functional pearl
- Backtracking
- 2005
(Show Context)
Citation Context ...d control [25, 26]. With this effect, an expression may access its delimited continuation [17–19] or delimited evaluation context as a first-class value. This ability is useful in backtracking search =-=[12, 18, 44, 59]-=-, direct-style representations of monads [30–32], the continuation-passing-style (CPS) transformation [17–19], partial evaluation [6, 7, 10, 16, 23, 33, 37, 47, 64], Web interactions [35, 53], mobile ... |

6 | 2001, ‘Towards Logical Understanding of Delimited Continuations
- Kameyama
(Show Context)
Citation Context ...ystems attach answer types to judgments and arrows as effect annotations [32, 34, 48, 61–63, 65]. These annotations obscure any logical interpretation of the types via the Curry-Howard correspondence =-=[4, 36, 42]-=-. For example, Danvy and Filinski [17] uses typing judgments of the form ρ, α ⊢ E : τ, β, where ρ is a typing environment, α and β are answer types, E is a term, and τ is its type. If E changes the an... |

5 |
Programming languages and lambda calculi. http://www.cs.utah.edu/plt/publications/pllc.pdf
- Felleisen, Flatt
- 2003
(Show Context)
Citation Context ...le to try to combine the coterms E1, # and E2, # into E1, (E2, #). A statement, of the form C $ E (pronounced “plug”), represents the term E plugged into the coterm C. It is a state of the CK machine =-=[25, 27, 28]-=-. A statement can also be understood as a zipper [41] over a term. Among the binary constructors, $ has the lowest precedence, and juxtaposition (for function application) the highest. All binary cons... |

4 |
Andrzej Filinski. 2002. Normalization and partial evaluation
- Dybjer
(Show Context)
Citation Context |

2 | Polymorphic type, region and effect - Talpin, Jouvelot - 1992 |

1 |
A syntactic approach to type soundness. Info. & Comp. 115(1):38–94. Derivation normalization Definition 4. The size of a derivation is the number of inferences (horizontal rules) in it. In particular, the undischarged identity inference x : U has size 0.
- Wright, Felleisen
- 1994
(Show Context)
Citation Context ...tion over the expression. However, when the language involves effects (especially control effects), it can be easier to specify and reason with a small-step semantics (especially evaluation contexts) =-=[68]-=-. A canonical effect that makes semantics and types harder to determine inductively is delimited control [25, 26]. With this effect, an expression may access its delimited continuation [17–19] or deli... |