skip to main content
research-article
Open Access

Handling delimited continuations with dependent types

Published:30 July 2018Publication History
Skip Abstract Section

Abstract

Dependent types are a powerful tool for maintaining program invariants. To take advantage of this aspect in real-world programming, efforts have been put into enriching dependently typed languages with missing constructs, most notably, effects. This paper presents a language that has two practically interesting ingredients: dependent inductive types, and the delimited control constructs shift and reset. When integrating delimited control into a dependently typed language, however, two challenges arise. First, the dynamic nature of control operators, which is the source of their expressiveness, can break fundamental language properties such as logical consistency and subject reduction. Second, CPS translations, which we often use to define the semantics of control operators, do not scale straightforwardly to dependently typed languages. We solve the former issue by restricting dependency of types, and the latter using answer-type polymorphism of pure terms. The main contribution of this paper is to give a sound type system of our language, as well as a type-preserving CPS translation. We also discuss various extensions, which would make our language more like a full-spectrum proof assistant but pose non-trivial issues.

Skip Supplemental Material Section

Supplemental Material

a69-cong.webm

References

  1. Danel Ahman. 2017a. Fibred Computational Effects. Ph.D. Dissertation. University of Edinburgh.Google ScholarGoogle Scholar
  2. Danel Ahman. 2017b. Handling Fibred Algebraic Effects. Proc. ACM Program. Lang. 2, POPL, Article 7 (Dec. 2017), 29 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Amal Ahmed and Matthias Blume. 2011. An Equivalence-Preserving CPS Translation via Multi-Language Semantics. In Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming (ICFP ’11). 431–444. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Thorsten Altenkirch and Bernhard Reus. 1999. Monadic Presentations of Lambda Terms Using Generalized Inductive Types. In Proceedings of the 13th International Workshop and 8th Annual Conference of the EACSL on Computer Science Logic (CSL ’99). Springer-Verlag, London, UK, 453–468. http://dl.acm.org/citation.cfm?id=647849.737066 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Abhishek Anand, A Appel, Greg Morrisett, Zoe Paraskevopoulou, Randy Pollack, Olivier Savary Bélanger, Matthieu Sozeau, and Matthew Weaver. 2017. CertiCoq: A verified compiler for Coq. In The Third International Workshop on Coq for Programming Languages (CoqPL).Google ScholarGoogle Scholar
  6. Zena M. Ariola, Hugo Herbelin, and Amr Sabry. 2009. A Type-Theoretic Foundation of Delimited Continuations. Higher Order and Symbolic Computation 22, 3 (Sept. 2009), 233–273. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Kenichi Asai and Yukiyoshi Kameyama. 2007. Polymorphic Delimited Continuations. In Proceedings of the 5th Asian Conference on Programming Languages and Systems (APLAS ’07). Springer-Verlag, Berlin, Heidelberg, 239–254. http: //dl.acm.org/citation.cfm?id=1784774.1784797 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Kenichi Asai and Oleg Kiselyov. 2011. Introduction to programming with shift and reset. In ACM SIGPLAN Continuation Workshop 2011.Google ScholarGoogle Scholar
  9. Kenichi Asai and Chihiro Uehara. 2018. Selective CPS Transformation for Shift and Reset. In Proceedings of the 2018 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-based Program Manipulation (PEPM ’18). 40–52. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Gilles Barthe, John Hatcliff, and Morten Heine B. Sørensen. 1999. CPS Translations and Applications: The Cube and Beyond. Higher-Order and Symbolic Computation 12, 2 (Sept. 1999), 125–170. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Gilles Barthe and Tarmo Uustalu. 2002. CPS Translating Inductive and Coinductive Types. In Proceedings of the 2002 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-based Program Manipulation (PEPM ’02). ACM, New York, NY, USA, 131–142. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Pierre Boutillier. 2012. A relaxation of Coq’s guard condition. In JFLA - Journées Francophones des langages applicatifs - 2012. Carnac, France, 1 – 14. https://hal.archives- ouvertes.fr/hal- 00651780Google ScholarGoogle Scholar
  13. William J. Bowman, Youyou Cong, Nick Rioux, and Amal Ahmed. 2017. Type-preserving CPS Translation of Σ and Π Types is Not Not Possible. Proc. ACM Program. Lang. 2, POPL, Article 22 (Dec. 2017), 33 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Youyou Cong and Kenichi Asai. 2018. Handling Delimited Continuations with Dependent Types (Technical Appendix). (June 2018). https://github.com/YouyouCong/icfp18/Google ScholarGoogle Scholar
  15. Thierry Coquand. 1989. Metamathematical investigations of a calculus of constructions. Ph.D. Dissertation. INRIA.Google ScholarGoogle Scholar
  16. Thierry Coquand and Christine Paulin. 1990. Inductively Defined Types. In Proceedings of the International Conference on Computer Logic (COLOG ’88). Springer-Verlag, London, UK, 50–66. http://dl.acm.org/citation.cfm?id=646125.758641 Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Pierre-Louis Curien and Hugo Herbelin. 2000. The duality of computation. In ACM sigplan notices, Vol. 35. ACM, 233–243. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Olivier Danvy. 1996. Type-directed Partial Evaluation. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’96). ACM, New York, NY, USA, 242–257. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Olivier Danvy and Andrzej Filinski. 1989. A functional abstraction of typed contexts. Technical Report. University of Copenhagen.Google ScholarGoogle Scholar
  20. Olivier Danvy and Andrzej Filinski. 1990. Abstracting control. In Proceedings of the 1990 ACM conference on LISP and functional programming. ACM, 151–160. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Olivier Danvy and Andrzej Filinski. 1992. Representing control: a study of the CPS transformation.Google ScholarGoogle Scholar
  22. Edsger W. Dijkstra. 1975. Guarded Commands, Nondeterminacy and Formal Derivation of Programs. Commun. ACM 18, 8 (Aug. 1975), 453–457. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Andrzej Filinski. 1994. Representing Monads. In Proceedings of the 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’94). ACM, New York, NY, USA, 446–457. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Matthew Flatt, Gang Yu, Robert Bruce Findler, and Matthias Felleisen. 2007. Adding Delimited and Composable Control to a Production Programming Environment. In Proceedings of the 12th ACM SIGPLAN International Conference on Functional Programming (ICFP ’07). ACM, New York, NY, USA, 165–176. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Yannick Forster, Ohad Kammar, Sam Lindley, and Matija Pretnar. 2017. On the Expressive Power of User-defined Effects: Effect Handlers, Monadic Reflection, Delimited Control. Proc. ACM Program. Lang. 1, ICFP, Article 13 (Aug. 2017), 29 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Eduardo Giménez. 1995. Codifying Guarded Definitions with Recursive Schemes. In Selected Papers from the International Workshop on Types for Proofs and Programs (TYPES ’94). Springer-Verlag, London, UK, 39–59. http://dl.acm.org/citation. cfm?id=646535.695850 Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Jean-Yves Girard. 1972. Interprétation fonctionnelle et élimination des coupures dans l’arithmétique. Ph.D. Dissertation. Université Paris VII.Google ScholarGoogle Scholar
  28. Georges Gonthier. 2008. The four colour theorem: Engineering of a formal proof. In Computer Mathematics. Springer, 333–333. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Timothy G. Griffin. 1990. A Formulae-as-types Notion of Control. In Proceedings of the 17th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’90). ACM, New York, NY, USA, 47–58. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Hugo Herbelin. 2005. On the degeneracy of Σ-types in presence of computational classical logic. In International Conference on Typed Lambda Calculi and Applications (TLCA ’05). Springer, 209–220. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Hugo Herbelin. 2012. A constructive proof of dependent choice, compatible with classical logic. In Proceedings of the 2012 27th Annual IEEE/ACM Symposium on Logic in Computer Science (LICS ’12). IEEE Computer Society, 365–374. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Hugo Herbelin and Silvia Ghilezan. 2008. An Approach to Call-by-name Delimited Continuations. In Proceedings of the 35th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’08). ACM, New York, NY, USA, 383–394. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Danko Ilik. 2012. Delimited control operators prove double-negation shift. Annals of Pure and Applied logic 163, 11 (2012), 1549–1559.Google ScholarGoogle ScholarCross RefCross Ref
  34. Limin Jia, Jianzhou Zhao, Vilhelm Sjöberg, and Stephanie Weirich. 2010. Dependent Types and Program Equivalence. In Proceedings of the 37th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’10). ACM, New York, NY, USA, 275–286. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Yukiyoshi Kameyama, Oleg Kiselyov, and Chung-chieh Shan. 2009. Shifting the Stage: Staging with Delimited Control. In Proceedings of the 2009 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation (PEPM ’09). ACM, New York, NY, USA, 111–120. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Oleg Kiselyov, Chung-chieh Shan, and Amr Sabry. 2006. Delimited dynamic binding. In The 33th ACM SIGPLAN-SIGACT symposium on Principles of programming languages (POPL ’06). ACM, 26–37. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Oleg Kiselyov and KC Sivaramakrishnan. 2016. Eff directly in OCaml. In ML Workshop.Google ScholarGoogle Scholar
  38. Shriram Krishnamurthi, Peter Walton Hopkins, Jay McCarthy, Paul T. Graunke, Greg Pettyjohn, and Matthias Felleisen. 2007. Implementation and Use of the PLT Scheme Web Server. Higher Order Symbolic Computation 20, 4 (Dec. 2007), 431–460. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Rodolphe Lepigre. 2016. A classical realizability model for a semantical value restriction. In European Symposium on Programming Languages and Systems (ESOP ’16). Springer, 476–502.Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Xavier Leroy. 2006. Formal certification of a compiler back-end, or: programming a compiler with a proof assistant. In 33rd ACM Symposium on Principles of Programming Languages (POPL ’06). 42–54. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Paul Blain Levy. 2012. Call-by-push-value: A Functional/imperative Synthesis. Vol. 2. Springer Science & Business Media.Google ScholarGoogle Scholar
  42. Marek Materzok and Dariusz Biernacki. 2011. Subtyping Delimited Continuations. In Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming (ICFP ’11). ACM, New York, NY, USA, 81–93. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Ulf Norell. 2007. Towards a practical programming language based on dependent type theory. Ph.D. Dissertation. Chalmers University of Technology.Google ScholarGoogle Scholar
  44. Michel Parigot. 1992. Lambda-My-Calculus: An Algorithmic Interpretation of Classical Natural Deduction. In Proceedings of the International Conference on Logic Programming and Automated Reasoning (LPAR ’92). Springer-Verlag, London, UK, 190–201. http://dl.acm.org/citation.cfm?id=645706.663989 Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Frank Pfenning and Christine Paulin-Mohring. 1990. Inductively Defined Types in the Calculus of Constructions. In Proceedings of the 5th International Conference on Mathematical Foundations of Programming Semantics. Springer-Verlag, London, UK, 209–228. http://dl.acm.org/citation.cfm?id=645736.666272 Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Chung-Chieh Shan. 2003. From shift and reset to polarized linear logic. (2003). Unpublished.Google ScholarGoogle Scholar
  47. Chung-chieh Shan. 2007. A static simulation of dynamic delimited control. Higher-Order and Symbolic Computation 20, 4 (2007), 371–401. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Matthieu Sozeau. 2008. Un environnement pour la programmation avec types dépendants. Ph.D. Dissertation. Université de Paris-Sud. Faculté des Sciences d’Orsay (Essonne).Google ScholarGoogle Scholar
  49. Nikhil Swamy, Juan Chen, Cédric Fournet, Pierre-Yves Strub, Karthikeyan Bhargavan, and Jean Yang. 2011. Secure Distributed Programming with Value-dependent Types. In Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming (ICFP ’11). ACM, New York, NY, USA, 266–278. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. Nikhil Swamy, Cătălin Hriţcu, Chantal Keller, Aseem Rastogi, Antoine Delignat-Lavaud, Simon Forest, Karthikeyan Bhargavan, Cédric Fournet, Pierre-Yves Strub, Markulf Kohlweiss, Jean-Karim Zinzindohoue, and Santiago ZanellaBéguelin. 2016. Dependent Types and Multi-monadic Effects in F*. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’16). ACM, New York, NY, USA, 256–270. Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. Asami Tanaka and Yukiyoshi Kameyama. 2012. A Call-by-Name CPS Hierarchy. In Functional and Logic Programming, Tom Schrijvers and Peter Thiemann (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 260–274. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. The Coq Development Team. 2018. The Coq Proof Assistant Reference Manual. https://coq.inria.fr/refman/Google ScholarGoogle Scholar
  53. Hayo Thielecke. 2003. From Control Effects to Typed Continuation Passing. In Proceedings of the 30th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages" (POPL ’03). Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. Matthijs Vákár. 2017. In Search of Effectful Dependent Types. Ph.D. Dissertation. Oxford University.Google ScholarGoogle Scholar
  55. Philip Wadler. 1989. Theorems for Free!. In Proceedings of the Fourth International Conference on Functional Programming Languages and Computer Architecture (FPCA ’89). ACM, ACM, New York, NY, USA, 347–359. Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. Benjamin Werner. 1994. Une Théorie des Constructions Inductives. Ph.D. Dissertation. Université Paris-Diderot - Paris VII. https://tel.archives- ouvertes.fr/tel- 00196524Google ScholarGoogle Scholar
  57. Andrew K Wright and Matthias Felleisen. 1994. A syntactic approach to type soundness. Information and computation 115, 1 (1994), 38–94. Google ScholarGoogle ScholarDigital LibraryDigital Library
  58. Noam Zeilberger. 2010. Polarity and the logic of delimited continuations. In Logic in Computer Science (LICS), 2010 25th Annual IEEE Symposium on. IEEE, 219–227. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Handling delimited continuations with dependent types

            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 Proceedings of the ACM on Programming Languages
              Proceedings of the ACM on Programming Languages  Volume 2, Issue ICFP
              September 2018
              1133 pages
              EISSN:2475-1421
              DOI:10.1145/3243631
              Issue’s Table of Contents

              Copyright © 2018 Owner/Author

              Publisher

              Association for Computing Machinery

              New York, NY, United States

              Publication History

              • Published: 30 July 2018
              Published in pacmpl Volume 2, Issue ICFP

              Permissions

              Request permissions about this article.

              Request Permissions

              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!