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.
Supplemental Material
Available for Download
The archive contains the source code of the OCaml library of contracts for higher-order sessions described in the paper, the source code of a number of illustrative examples (including those shown in the paper), and the API documentation automatically extracted from the library. The provided README.md file contains instructions for compiling the library and the examples.
- 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 Scholar
Cross Ref
- Massimo Bartoletti, Emilio Tuosto, and Roberto Zunino. 2012. Contract-Oriented Computing in CO2. Scientific Annals of Computer Science 22, 1 (2012), 5–60. Google Scholar
Cross Ref
- Matthias Blume and David A. McAllester. 2006. Sound and complete models of contracts. Journal of Functional Programming 16, 4-5 (2006), 375–414.Google Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Cross Ref
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Tim Disney, Cormac Flanagan, and Jay McCarthy. 2011. Temporal higher-order contracts. In ACM SIGPLAN Notices, Vol. 46. ACM, 176–188. Google Scholar
Digital Library
- Robert Bruce Findler and Matthias Blume. 2006. Contracts as Pairs of Projections. In Proceedings of FLOPS’06 (LNCS 3945). Springer, 226–241. Google Scholar
Digital Library
- Robert Bruce Findler and Matthias Felleisen. 2002. Contracts for higher-order functions. In Proceedings of ICFP’02. ACM, 48–59. Google Scholar
Digital Library
- Jacques Garrigue and Jacques Le Normand. 2011. Adding GADTs to OCaml: the direct approach. In Proceedings of ACM SIGPLAN Workshop on ML.Google Scholar
- Simon J. Gay and Malcolm Hole. 2005. Subtyping for Session Types in the π -calculus. Acta Informatica 42, 2-3 (2005), 191–225.Google Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Michael Greenberg, Benjamin C. Pierce, and Stephanie Weirich. 2012. Contracts made manifest. Journal of Functional Programming 22, 3 (2012), 225–274. Google Scholar
Digital Library
- Jessica Gronski and Cormac Flanagan. 2007. Unifying Hybrid Types and Contracts. In Proceedings of TFP’07, Vol. 8. Intellect, 54–70.Google Scholar
- 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 Scholar
Digital Library
- Kohei Honda. 1993. Types for dyadic interaction. In Proceedings of CONCUR’93 (LNCS 715). Springer, 509–523. Google Scholar
Cross Ref
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- Kenneth Knowles and Cormac Flanagan. 2010. Hybrid type checking. ACM Transactions on Programming Languages and Systems 32, 2 (2010). Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- Bertrand Meyer. 1992. Design by Contract. In Advances in Object-oriented Software Engineering. Prentice-Hall, 1–50.Google Scholar
- 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 Scholar
Digital Library
- Luca Padovani. 2017. A Simple Library Implementation of Binary Sessions. Journal of Functional Programming 27 (2017).Google Scholar
- António Ravara and Vasco Thudichum Vasconcelos. 2000. Typing Non-uniform Concurrent Objects. In Proceedings of CONCUR’00 (LNCS 1877). Springer, 474–488. Google Scholar
Cross Ref
- Christophe Scholliers, Éric Tanter, and Wolfgang De Meuter. 2015. Computational contracts. Science of Computer Programming 98 (2015), 360–375. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Peter Thiemann. 2014. Session Types with Gradual Typing. In Proceedings of TGC’14 (LNCS 8902). Springer, 144–158. Google Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- Jesse A. Tov and Riccardo Pucella. 2010. Stateful Contracts for Affine Types. In Proceedings of ESOP’10 (LNCS 6012). Springer, 550–569. Google Scholar
Digital Library
- Jesse A. Tov and Riccardo Pucella. 2011. Practical affine types. In Proceedings of POPL’11. ACM, 447–458. Google Scholar
Digital Library
- Philip Wadler. 2015. A Complement to Blame. In Proceedings of SNAPL’15 (LIPIcs 32). Schloss Dagstuhl, 309–320.Google Scholar
- 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 Scholar
Digital Library
Index Terms
Chaperone contracts for higher-order sessions
Recommendations
Temporal higher-order contracts
ICFP '11Behavioral contracts are embraced by software engineers because they document module interfaces, detect interface violations, and help identify faulty modules (packages, classes, functions, etc). This paper extends prior higher-order contract systems to ...
Contracts for higher-order functions
Assertions play an important role in the construction of robust software. Their use in programming languages dates back to the 1970s. Eiffel, an object-oriented programming language, wholeheartedly adopted assertions and developed the "Design by ...
Temporal higher-order contracts
ICFP '11: Proceedings of the 16th ACM SIGPLAN international conference on Functional programmingBehavioral contracts are embraced by software engineers because they document module interfaces, detect interface violations, and help identify faulty modules (packages, classes, functions, etc). This paper extends prior higher-order contract systems to ...






Comments