Abstract
We present a type system with subtyping for first-class delimited continuations that generalizes Danvy and Filinski's type system for shift and reset by maintaining explicit information about the types of contexts in the metacontext. We exploit this generalization by considering the control operators known as shift0 and reset0 that can access arbitrary contexts in the metacontext. We use subtyping to control the level of information about the metacontext the expression actually requires and in particular to coerce pure expressions into effectful ones. For this type system we prove strong type soundness and termination of evaluation and we present a provably correct type reconstruction algorithm. We also introduce two CPS translations for shift0 and reset0: one targeting the untyped lambda calculus, and another - type-directed - targeting the simply-typed lambda calculus. The latter translation preserves typability and is selective in that it keeps pure expressions in direct style.
Supplemental Material
- M. S. Ager, D. Biernacki, O. Danvy, and J. Midtgaard. A functional correspondence between evaluators and abstract machines. In D. Miller, editor, Proceedings of the Fifth ACM-SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP'03), pages 8--19, Uppsala, Sweden, Aug. 2003. ACM Press. Google Scholar
Digital Library
- K. Asai and Y. Kameyama. Polymorphic delimited continuations. In Proceedings of the Fifth Asian symposium on Programming Languages and Systems, APLAS'07, number 4807 in Lecture Notes in Computer Science, pages 239--254, Singapore, Dec. 2007. Google Scholar
Digital Library
- V. Balat and O. Danvy. Memoization in type-directed partial evaluation. In D. Batory, C. Consel, and W. Taha, editors, Proceedings of the 2002 ACM SIGPLAN/SIGSOFT Conference on Generative Programming and Component Engineering, GPCE 2002, number 2487 in Lecture Notes in Computer Science, pages 78--92, Pittsburgh, Pennsylvania, Oct. 2002. Springer-Verlag. Google Scholar
Digital Library
- C. Barker. Continuations in natural language. In H. Thielecke, editor, Proceedings of the Fourth ACM SIGPLAN Workshop on Continuations (CW'04), Technical report CSR-04-1, Department of Computer Science, Queen Mary's College, pages 1--11, Venice, Italy, Jan. 2004.Google Scholar
- M. Biernacka and D. Biernacki. A context-based approach to proving termination of evaluation. In Proceedings of the 25th Annual Conference on Mathematical Foundations of Programming Semantics (MFPS XXV), Oxford, UK, Apr. 2009.Google Scholar
Digital Library
- M. Biernacka and D. Biernacki. Context-based proofs of termination for typed delimited-control operators. In F. J. López-Fraguas, editor, Proceedings of the 11th ACM-SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP'09), Coimbra, Portugal, Sept. 2009. ACM Press. Google Scholar
Digital Library
- M. Biernacka and O. Danvy. A syntactic correspondence between context-sensitive calculi and abstract machines. Theoretical Computer Science, 375 (1-3): 76--108, 2007. Google Scholar
Digital Library
- M. Biernacka and O. Danvy. A concrete framework for environment machines. ACM Transactions on Computational Logic, 9 (1): 1--30, 2007. Google Scholar
Digital Library
- M. Biernacka, D. Biernacki, and O. Danvy. An operational foundation for delimited continuations in the CPS hierarchy. Logical Methods in Computer Science, 1 (2:5): 1--39, Nov. 2005. A preliminary version was presented at the Fourth ACM SIGPLAN Workshop on Continuations (CW'04).Google Scholar
Cross Ref
- D. Biernacki, O. Danvy, and K. Millikin. A dynamic continuation-passing style for dynamic delimited continuations. Technical Report BRICS RS-05-16, DAIMI, Department of Computer Science, Aarhus University, Aarhus, Denmark, May 2005.Google Scholar
- P. Cousot and R. Cousot. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In R. Sethi, editor, Proceedings of the Fourth Annual ACM Symposium on Principles of Programming Languages, pages 238--252, Los Angeles, California, Jan. 1977. ACM Press. Google Scholar
Digital Library
- O. Danvy. Type-directed partial evaluation. In G. L. Steele Jr., editor, Proceedings of the Twenty-Third Annual ACM Symposium on Principles of Programming Languages, pages 242--257, St. Petersburg Beach, Florida, Jan. 1996. ACM Press. Google Scholar
Digital Library
- O. Danvy and A. Filinski. A functional abstraction of typed contexts. DIKU Rapport 89/12, DIKU, Computer Science Department, University of Copenhagen, Copenhagen, Denmark, July 1989.Google Scholar
- O. Danvy and A. Filinski. Abstracting control. In M. Wand, editor, Proceedings of the 1990 ACM Conference on Lisp and Functional Programming, pages 151--160, Nice, France, June 1990. ACM Press. Google Scholar
Digital Library
- P. Dybjer and A. Filinski. Normalization and partial evaluation. In G. Barthe, P. Dybjer, L. Pinto, and J. Saraiva, editors, Applied Semantics - Advanced Lectures, number 2395 in Lecture Notes in Computer Science, pages 137--192, Caminha, Portugal, Sept. 2000. Springer-Verlag. Google Scholar
Digital Library
- R. K. Dybvig, S. Peyton-Jones, and A. Sabry. A monadic framework for delimited continuations. Journal of Functional Programming, 17 (6): 687--730, 2007. Google Scholar
Digital Library
- M. Felleisen. The theory and practice of first-class prompts. In J. Ferrante and P. Mager, editors, Proceedings of the Fifteenth Annual ACM Symposium on Principles of Programming Languages, pages 180--190, San Diego, California, Jan. 1988. ACM Press. Google Scholar
Digital Library
- A. Filinski. Representing monads. In H.-J. Boehm, editor, Proceedings of the Twenty-First Annual ACM Symposium on Principles of Programming Languages, pages 446--457, Portland, Oregon, Jan. 1994. ACM Press. Google Scholar
Digital Library
- A. Filinski. Representing layered monads. In A. Aiken, editor, Proceedings of the Twenty-Sixth Annual ACM Symposium on Principles of Programming Languages, pages 175--188, San Antonio, Texas, Jan. 1999. ACM Press. Google Scholar
Digital Library
- R. Harper, B. F. Duba, and D. MacQueen. Typing first-class continuations in ML. Journal of Functional Programming, 3 (4): 465--484, Oct. 1993. A preliminary version was presented at the Eighteenth Annual ACM Symposium on Principles of Programming Languages (POPL 1991). Google Scholar
Digital Library
- F. Henglein. Syntactic properties of polymorphic subtyping. Technical Report Semantics Report D-293, DIKU, Computer Science Department, University of Copenhagen, May 1996.Google Scholar
- Y. Kameyama and M. Hasegawa. A sound and complete axiomatization of delimited continuations. In O. Shivers, editor, Proceedings of the 2003 ACM SIGPLAN International Conference on Functional Programming (ICFP'03), SIGPLAN Notices, Vol. 38, No. 9, pages 177--188, Uppsala, Sweden, Aug. 2003. ACM Press. Google Scholar
Digital Library
- R. Kelsey, W. Clinger, and J. Rees, editors. Revised5 report on the algorithmic language Scheme. Higher-Order and Symbolic Computation, 11 (1): 7--105, 1998. Google Scholar
Digital Library
- J. Kim, K. Yi, and O. Danvy. Assessing the overhead of ML exceptions by selective CPS transformation. In G. Morrisett, editor, Record of the 1998 ACM SIGPLAN Workshop on ML and its Applications, Baltimore, Maryland, Sept. 1998.Google Scholar
- O. Kiselyov and C. Shan. Delimited continuations in operating systems. In B. Kokinov, D. C. Richardson, T. R. Roth-Berghofer, and L. Vieu, editors, Modeling and Using Context, 6th International and Interdisciplinary Conference, CONTEXT 2007, number 4635 in Lecture Notes in Artificial Intelligence, pages 291--302, Roskilde, Denmark, Aug. 2007. Springer. Google Scholar
Digital Library
- O. Kiselyov and C. Shan. A substructural type system for delimited continuations. In S. R. D. Rocca, editor, Typed Lambda Calculi and Applications, 8th International Conference, TLCA 2007, number 4583 in Lecture Notes in Computer Science, pages 223--239, Paris, France, June 2007. Springer-Verlag. Google Scholar
Digital Library
- L. R. Nielsen. A selective CPS transformation. In S. Brookes and M. Mislove, editors, Proceedings of the 17th Annual Conference on Mathematical Foundations of Programming Semantics, volume 45 of Electronic Notes in Theoretical Computer Science, pages 201--222, Aarhus, Denmark, May 2001. Elsevier Science Publishers.Google Scholar
- G. D. Plotkin. Call-by-name, call-by-value and the λ-calculus. Theoretical Computer Science, 1: 125--159, 1975.Google Scholar
Cross Ref
- J. C. Reynolds. Definitional interpreters for higher-order programming languages. In Proceedings of 25th ACM National Conference, pages 717--740, Boston, Massachusetts, 1972. Reprinted in Higher-Order and Symbolic Computation 11(4):363--397, 1998, with a foreword {30}. Google Scholar
Digital Library
- J. C. Reynolds. Definitional interpreters revisited. Higher-Order and Symbolic Computation, 11 (4): 355--361, 1998. Google Scholar
Digital Library
- T. Rompf, I. Maier, and M. Odersky. Implementing first-class polymorphic delimited continuations by a type-directed selective cps-transform. In A. Tolmach, editor, Proceedings of the 2009 ACM SIGPLAN International Conference on Functional Programming (ICFP'09), pages 317--328, Edinburgh, UK, Aug. 2009. ACM Press. Google Scholar
Digital Library
- C. Shan. A static simulation of dynamic delimited control. Higher-Order and Symbolic Computation, 20 (4): 371--401, 2007. Google Scholar
Digital Library
- E. Sumii. An implementation of transparent migration on standard Scheme. In M. Felleisen, editor, Proceedings of the Workshop on Scheme and Functional Programming, Technical Report 00-368, Rice University, pages 61--64, Montréal, Canada, Sept. 2000.Google Scholar
Index Terms
Subtyping delimited continuations
Recommendations
Subtyping delimited continuations
ICFP '11: Proceedings of the 16th ACM SIGPLAN international conference on Functional programmingWe present a type system with subtyping for first-class delimited continuations that generalizes Danvy and Filinski's type system for shift and reset by maintaining explicit information about the types of contexts in the metacontext. We exploit this ...
Polymorphic delimited continuations
APLAS'07: Proceedings of the 5th Asian conference on Programming languages and systemsThis paper presents a polymorphic type system for a language with delimited control operators, shift and reset. Based on the monomorphic type system by Danvy and Filinski, the proposed type system allows pure expressions to be polymorphic. Thanks to the ...
Typed dynamic control operators for delimited continuations
FLOPS'08: Proceedings of the 9th international conference on Functional and logic programmingWe study the dynamic control operators for delimited continuations, control and prompt. Based on recent developments on purely functional CPS translations for them, we introduce a polymorphically typed calculus for these control operators which allows ...







Comments