skip to main content
research-article
Open Access
Artifacts Available
Artifacts Evaluated & Reusable

Chaperone contracts for higher-order sessions

Published:29 August 2017Publication History
Skip Abstract Section

Abstract

Contracts have proved to be an effective mechanism that helps developers in identifying those modules of a program that violate the contracts of the functions and objects they use. In recent years, sessions have established as a key mechanism for realizing inter-module communications in concurrent programs. Just like values flow into or out of a function or object, messages are sent on, and received from, a session endpoint. Unlike conventional functions and objects, however, the kind, direction, and properties of messages exchanged in a session may vary over time, as the session progresses. This feature of sessions calls for contracts that evolve along with the session they describe.

In this work, we extend to sessions the notion of chaperone contract (roughly, a contract that applies to a mutable object) and investigate the ramifications of contract monitoring in a higher-order language that features sessions. We give a characterization of correct module, one that honors the contracts of the sessions it uses, and prove a blame theorem. Guided by the calculus, we describe a lightweight implementation of monitored sessions as an OCaml module with which programmers can benefit from static session type checking and dynamic contract monitoring using an off-the-shelf version of OCaml.

Skip Supplemental Material Section

Supplemental Material

References

  1. Massimo Bartoletti, Alceste Scalas, Emilio Tuosto, and Roberto Zunino. 2013. Honesty by Typing. In Proceedings of FMOODS/FORTE’13 (LNCS 7892). Springer, 305–320. Google ScholarGoogle ScholarCross RefCross Ref
  2. Massimo Bartoletti, Emilio Tuosto, and Roberto Zunino. 2012. Contract-Oriented Computing in CO2. Scientific Annals of Computer Science 22, 1 (2012), 5–60. Google ScholarGoogle ScholarCross RefCross Ref
  3. Matthias Blume and David A. McAllester. 2006. Sound and complete models of contracts. Journal of Functional Programming 16, 4-5 (2006), 375–414.Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Laura Bocchi, Tzu-Chun Chen, Romain Demangeon, Kohei Honda, and Nobuko Yoshida. 2013. Monitoring Networks through Multiparty Session Types. In Proceedings FMOODS/FORTE’13 (LNCS 7892). Springer, 50–65. Google ScholarGoogle ScholarCross RefCross Ref
  5. Laura Bocchi, Kohei Honda, Emilio Tuosto, and Nobuko Yoshida. 2010. A Theory of Design-by-Contract for Distributed Multiparty Interactions. In Proceedings of CONCUR’10 (LNCS 6269). Springer, 162–176. Google ScholarGoogle ScholarCross RefCross Ref
  6. Tzu-Chun Chen, Laura Bocchi, Pierre-Malo Deniélou, Kohei Honda, and Nobuko Yoshida. 2011. Asynchronous Distributed Monitoring for Multiparty Session Enforcement. In Proceedings of TGC’11 (LNCS 7173). Springer, 25–45.Google ScholarGoogle Scholar
  7. Christos Dimoulas and Matthias Felleisen. 2011. On contract satisfaction in a higher-order world. ACM Transactions on Programming Languages and Systems 33, 5 (2011), 16.Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Christos Dimoulas, Robert Bruce Findler, Cormac Flanagan, and Matthias Felleisen. 2011. Correct blame for contracts: no more scapegoating. In Proceedings of POPL’11. ACM, 215–226. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Christos Dimoulas, Sam Tobin-Hochstadt, and Matthias Felleisen. 2012. Complete Monitors for Behavioral Contracts. In Proceedings of ESOP’12 (LNCS 7211). Springer, 214–233. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Tim Disney, Cormac Flanagan, and Jay McCarthy. 2011. Temporal higher-order contracts. In ACM SIGPLAN Notices, Vol. 46. ACM, 176–188. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Robert Bruce Findler and Matthias Blume. 2006. Contracts as Pairs of Projections. In Proceedings of FLOPS’06 (LNCS 3945). Springer, 226–241. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Robert Bruce Findler and Matthias Felleisen. 2002. Contracts for higher-order functions. In Proceedings of ICFP’02. ACM, 48–59. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Jacques Garrigue and Jacques Le Normand. 2011. Adding GADTs to OCaml: the direct approach. In Proceedings of ACM SIGPLAN Workshop on ML.Google ScholarGoogle Scholar
  14. Simon J. Gay and Malcolm Hole. 2005. Subtyping for Session Types in the π -calculus. Acta Informatica 42, 2-3 (2005), 191–225.Google ScholarGoogle ScholarCross RefCross Ref
  15. Simon J. Gay and Vasco Thudichum Vasconcelos. 2010. Linear type theory for asynchronous session types. Journal of Functional Programming 20, 1 (2010), 19–50. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Simon J. Gay, Vasco Thudichum Vasconcelos, António Ravara, Nils Gesbert, and Alexandre Z. Caldeira. 2010. Modular session types for distributed object-oriented programming. In Proceedings of POPL’10. ACM, 299–312. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Michael Greenberg, Benjamin C. Pierce, and Stephanie Weirich. 2012. Contracts made manifest. Journal of Functional Programming 22, 3 (2012), 225–274. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Jessica Gronski and Cormac Flanagan. 2007. Unifying Hybrid Types and Contracts. In Proceedings of TFP’07, Vol. 8. Intellect, 54–70.Google ScholarGoogle Scholar
  19. Ralf Hinze, Johan Jeuring, and Andres Löh. 2006. Typed Contracts for Functional Programming. In Proceedings of FLOPS’06 (LNCS 3945). Springer, 208–225. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Kohei Honda. 1993. Types for dyadic interaction. In Proceedings of CONCUR’93 (LNCS 715). Springer, 509–523. Google ScholarGoogle ScholarCross RefCross Ref
  21. Kohei Honda, Vasco T. Vasconcelos, and Makoto Kubo. 1998. Language primitives and type disciplines for structured communication-based programming. In Proceedings of ESOP’98 (LNCS 1381). Springer, 122–138. Google ScholarGoogle ScholarCross RefCross Ref
  22. Limin Jia, Hannah Gommerstadt, and Frank Pfenning. 2016. Monitors and blame assignment for higher-order session types. In Proceedings of POPL’16. ACM, 582–594. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Kenneth Knowles and Cormac Flanagan. 2010. Hybrid type checking. ACM Transactions on Programming Languages and Systems 32, 2 (2010). Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Naoki Kobayashi, Benjamin C. Pierce, and David N. Turner. 1999. Linearity and the pi-calculus. ACM Transactions on Programming Languages and Systems 21, 5 (1999), 914–947. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Hernán Melgratti and Luca Padovani. 2017. Chaperone Contracts for Higher-Order Sessions. (2017). Retrieved Jul 2, 2017 from http://hdl.handle.net/2318/164Google ScholarGoogle Scholar
  26. Bertrand Meyer. 1992. Design by Contract. In Advances in Object-oriented Software Engineering. Prentice-Hall, 1–50.Google ScholarGoogle Scholar
  27. Phúc C Nguyen, Sam Tobin-Hochstadt, and David Van Horn. 2014. Soft contract verification. In ACM SIGPLAN Notices, Vol. 49. ACM, 139–152.Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Luca Padovani. 2017. A Simple Library Implementation of Binary Sessions. Journal of Functional Programming 27 (2017).Google ScholarGoogle Scholar
  29. António Ravara and Vasco Thudichum Vasconcelos. 2000. Typing Non-uniform Concurrent Objects. In Proceedings of CONCUR’00 (LNCS 1877). Springer, 474–488. Google ScholarGoogle ScholarCross RefCross Ref
  30. Christophe Scholliers, Éric Tanter, and Wolfgang De Meuter. 2015. Computational contracts. Science of Computer Programming 98 (2015), 360–375. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. T. Stephen Strickland, Sam Tobin-Hochstadt, Robert Bruce Findler, and Matthew Flatt. 2012. Chaperones and impersonators: run-time support for reasonable interposition. In Proceedings of OOPSLA’12. ACM, 943–962. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Cameron Swords, Amr Sabry, and Sam Tobin-Hochstadt. 2015. Expressing contract monitors as patterns of communication. In ACM SIGPLAN Notices, Vol. 50. ACM, 387–399. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Peter Thiemann. 2014. Session Types with Gradual Typing. In Proceedings of TGC’14 (LNCS 8902). Springer, 144–158. Google ScholarGoogle ScholarCross RefCross Ref
  34. Bernardo Toninho, Luís Caires, and Frank Pfenning. 2011. Dependent session types via intuitionistic linear type theory. In Proceedings of PPDP’11. ACM, 161–172. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Bernardo Toninho and Nobuko Yoshida. 2016. Certifying Data in Multiparty Session Types. In A List of Successes That Can Change the World - Essays Dedicated to Philip Wadler on the Occasion of His 60th Birthday (LNCS 9600). Springer, 433–458. Google ScholarGoogle ScholarCross RefCross Ref
  36. Jesse A. Tov and Riccardo Pucella. 2010. Stateful Contracts for Affine Types. In Proceedings of ESOP’10 (LNCS 6012). Springer, 550–569. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Jesse A. Tov and Riccardo Pucella. 2011. Practical affine types. In Proceedings of POPL’11. ACM, 447–458. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Philip Wadler. 2015. A Complement to Blame. In Proceedings of SNAPL’15 (LIPIcs 32). Schloss Dagstuhl, 309–320.Google ScholarGoogle Scholar
  39. Philip Wadler and Robert Bruce Findler. 2009. Well-Typed Programs Can’t Be Blamed. In Proceedings of ESOP’09 (LNCS 5502). Springer, 1–16. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Chaperone contracts for higher-order sessions

            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

            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!