Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Chaperone contracts for higher-order sessions

Published: 29 August 2017 Publication History

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.

Supplementary Material

Auxiliary Archive (icfp17-main54-s.zip)
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.

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.
[2]
Massimo Bartoletti, Emilio Tuosto, and Roberto Zunino. 2012. Contract-Oriented Computing in CO2. Scientific Annals of Computer Science 22, 1 (2012), 5–60.
[3]
Matthias Blume and David A. McAllester. 2006. Sound and complete models of contracts. Journal of Functional Programming 16, 4-5 (2006), 375–414.
[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.
[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.
[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.
[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.
[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.
[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.
[10]
Tim Disney, Cormac Flanagan, and Jay McCarthy. 2011. Temporal higher-order contracts. In ACM SIGPLAN Notices, Vol. 46. ACM, 176–188.
[11]
Robert Bruce Findler and Matthias Blume. 2006. Contracts as Pairs of Projections. In Proceedings of FLOPS’06 (LNCS 3945). Springer, 226–241.
[12]
Robert Bruce Findler and Matthias Felleisen. 2002. Contracts for higher-order functions. In Proceedings of ICFP’02. ACM, 48–59.
[13]
Jacques Garrigue and Jacques Le Normand. 2011. Adding GADTs to OCaml: the direct approach. In Proceedings of ACM SIGPLAN Workshop on ML.
[14]
Simon J. Gay and Malcolm Hole. 2005. Subtyping for Session Types in the π -calculus. Acta Informatica 42, 2-3 (2005), 191–225.
[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.
[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.
[17]
Michael Greenberg, Benjamin C. Pierce, and Stephanie Weirich. 2012. Contracts made manifest. Journal of Functional Programming 22, 3 (2012), 225–274.
[18]
Jessica Gronski and Cormac Flanagan. 2007. Unifying Hybrid Types and Contracts. In Proceedings of TFP’07, Vol. 8. Intellect, 54–70.
[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.
[20]
Kohei Honda. 1993. Types for dyadic interaction. In Proceedings of CONCUR’93 (LNCS 715). Springer, 509–523.
[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.
[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.
[23]
Kenneth Knowles and Cormac Flanagan. 2010. Hybrid type checking. ACM Transactions on Programming Languages and Systems 32, 2 (2010).
[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.
[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/164
[26]
Bertrand Meyer. 1992. Design by Contract. In Advances in Object-oriented Software Engineering. Prentice-Hall, 1–50.
[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.
[28]
Luca Padovani. 2017. A Simple Library Implementation of Binary Sessions. Journal of Functional Programming 27 (2017).
[29]
António Ravara and Vasco Thudichum Vasconcelos. 2000. Typing Non-uniform Concurrent Objects. In Proceedings of CONCUR’00 (LNCS 1877). Springer, 474–488.
[30]
Christophe Scholliers, Éric Tanter, and Wolfgang De Meuter. 2015. Computational contracts. Science of Computer Programming 98 (2015), 360–375.
[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.
[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.
[33]
Peter Thiemann. 2014. Session Types with Gradual Typing. In Proceedings of TGC’14 (LNCS 8902). Springer, 144–158.
[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.
[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.
[36]
Jesse A. Tov and Riccardo Pucella. 2010. Stateful Contracts for Affine Types. In Proceedings of ESOP’10 (LNCS 6012). Springer, 550–569.
[37]
Jesse A. Tov and Riccardo Pucella. 2011. Practical affine types. In Proceedings of POPL’11. ACM, 447–458.
[38]
Philip Wadler. 2015. A Complement to Blame. In Proceedings of SNAPL’15 (LIPIcs 32). Schloss Dagstuhl, 309–320.
[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.

Cited By

View all
  • (2024)Discourje: Run-Time Verification of Communication Protocols in Clojure — Live at LastFormal Methods10.1007/978-3-031-71177-0_11(158-166)Online publication date: 13-Sep-2024
  • (2023)Intrinsically Typed Sessions with Callbacks (Functional Pearl)Proceedings of the ACM on Programming Languages10.1145/36078547:ICFP(711-739)Online publication date: 30-Aug-2023
  • (2023)ElixirST: A session-based type system for Elixir modulesJournal of Logical and Algebraic Methods in Programming10.1016/j.jlamp.2023.100891135(100891)Online publication date: Oct-2023
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Proceedings of the ACM on Programming Languages
Proceedings of the ACM on Programming Languages  Volume 1, Issue ICFP
September 2017
1173 pages
EISSN:2475-1421
DOI:10.1145/3136534
Issue’s Table of Contents
This work is licensed under a Creative Commons Attribution International 4.0 License.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 29 August 2017
Published in PACMPL Volume 1, Issue ICFP

Permissions

Request permissions for this article.

Check for updates

Badges

Author Tags

  1. Chaperone contracts
  2. OCaml
  3. blame soundness
  4. sessions

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)55
  • Downloads (Last 6 weeks)9
Reflects downloads up to 10 Nov 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Discourje: Run-Time Verification of Communication Protocols in Clojure — Live at LastFormal Methods10.1007/978-3-031-71177-0_11(158-166)Online publication date: 13-Sep-2024
  • (2023)Intrinsically Typed Sessions with Callbacks (Functional Pearl)Proceedings of the ACM on Programming Languages10.1145/36078547:ICFP(711-739)Online publication date: 30-Aug-2023
  • (2023)ElixirST: A session-based type system for Elixir modulesJournal of Logical and Algebraic Methods in Programming10.1016/j.jlamp.2023.100891135(100891)Online publication date: Oct-2023
  • (2023)Reasoning About Choreographic ProgramsCoordination Models and Languages10.1007/978-3-031-35361-1_8(144-162)Online publication date: 15-Jun-2023
  • (2022)Session Fidelity for ElixirST: A Session-Based Type System for Elixir ModulesElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.365.2365(17-36)Online publication date: 9-Aug-2022
  • (2022)Session-typed concurrent contractsJournal of Logical and Algebraic Methods in Programming10.1016/j.jlamp.2021.100731124(100731)Online publication date: Jan-2022
  • (2018)Session-Typed Concurrent ContractsProgramming Languages and Systems10.1007/978-3-319-89884-1_27(771-798)Online publication date: 14-Apr-2018

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media