skip to main content
research-article

Subtyping delimited continuations

Published:19 September 2011Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

_talk8.mp4

References

  1. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle Scholar
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. M. Biernacka and O. Danvy. A concrete framework for environment machines. ACM Transactions on Computational Logic, 9 (1): 1--30, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarCross RefCross Ref
  10. 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 ScholarGoogle Scholar
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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 ScholarGoogle Scholar
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. F. Henglein. Syntactic properties of polymorphic subtyping. Technical Report Semantics Report D-293, DIKU, Computer Science Department, University of Copenhagen, May 1996.Google ScholarGoogle Scholar
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  24. 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 ScholarGoogle Scholar
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  27. 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 ScholarGoogle Scholar
  28. G. D. Plotkin. Call-by-name, call-by-value and the λ-calculus. Theoretical Computer Science, 1: 125--159, 1975.Google ScholarGoogle ScholarCross RefCross Ref
  29. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  30. J. C. Reynolds. Definitional interpreters revisited. Higher-Order and Symbolic Computation, 11 (4): 355--361, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  32. C. Shan. A static simulation of dynamic delimited control. Higher-Order and Symbolic Computation, 20 (4): 371--401, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. 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 ScholarGoogle Scholar

Index Terms

  1. Subtyping delimited continuations

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 46, Issue 9
        ICFP '11
        September 2011
        456 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2034574
        Issue’s Table of Contents
        • cover image ACM Conferences
          ICFP '11: Proceedings of the 16th ACM SIGPLAN international conference on Functional programming
          September 2011
          470 pages
          ISBN:9781450308656
          DOI:10.1145/2034773

        Copyright © 2011 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 19 September 2011

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!