Abstract
Session types statically guarantee that communication complies with a protocol. However, most accounts of session typing do not account for failure, which means they are of limited use in real applications---especially distributed applications---where failure is pervasive.
We present the first formal integration of asynchronous session types with exception handling in a functional programming language. We define a core calculus which satisfies preservation and progress properties, is deadlock free, confluent, and terminating.
We provide the first implementation of session types with exception handling for a fully-fledged functional programming language, by extending the Links web programming language; our implementation draws on existing work on effect handlers. We illustrate our approach through a running example of two-factor authentication, and a larger example of a session-based chat application where communication occurs over session-typed channels and disconnections are handled gracefully.
Supplemental Material
- Manuel Adameit, Kirstin Peters, and Uwe Nestmann. 2017. Session types for link failures. In FORTE (Lecture Notes in Computer Science), Vol. 10321. Springer, 1–16.Google Scholar
- H. P. Barendregt. 1984. The Lambda Calculus Its Syntax and Semantics (revised ed.). Vol. 103. North Holland.Google Scholar
- Nick Benton and Andrew Kennedy. 2001. Exceptional Syntax. Journal of Functional Programming 11, 4 (2001), 395–410. Google Scholar
Digital Library
- Luís Caires and Jorge A Pérez. 2017. Linearity, control effects, and behavioral types. In ESOP (Lecture Notes in Computer Science). Springer, 229–259. Google Scholar
Digital Library
- Luís Caires and Frank Pfenning. 2010. Session types as intuitionistic linear propositions. In CONCUR (Lecture Notes in Computer Science), Vol. 10. Springer, 222–236. Google Scholar
Digital Library
- Marco Carbone, Ornela Dardha, and Fabrizio Montesi. 2014. Progress as compositional lock-freedom. In COORDINATION (Lecture Notes in Computer Science). Springer, 49–64. Google Scholar
Digital Library
- Marco Carbone, Kohei Honda, and Nobuko Yoshida. 2008. Structured interactional exceptions in session types. In CONCUR (Lecture Notes in Computer Science). Springer, 402–417. Google Scholar
Digital Library
- Marco Carbone, Sam Lindley, Fabrizio Montesi, Carsten Schürmann, and Philip Wadler. 2016. Coherence generalises duality: A logical explanation of multiparty session types. In CONCUR (LIPIcs), Vol. 59. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 33:1–33:15.Google Scholar
- Tzu-Chun Chen, Malte Viering, Andi Bejleri, Lukasz Ziarek, and Patrick Eugster. 2016. A type theory for robust failure handling in distributed systems. In FORTE (Lecture Notes in Computer Science), Vol. 9688. Springer, 96–113. Google Scholar
Digital Library
- David Gerard Clarke. 2003. Object Ownership and Containment. Ph.D. Dissertation. New South Wales, Australia. AAI0806678.Google Scholar
- Ezra Cooper. 2009. Programming Language Features for Web Application Development. Ph.D. Dissertation. University of Edinburgh.Google Scholar
- Ezra Cooper, Sam Lindley, Philip Wadler, and Jeremy Yallop. 2007. Links: Web programming without tiers. In FMCO (Lecture Notes in Computer Science). Springer, 266–296. Google Scholar
Digital Library
- Ornela Dardha, Elena Giachino, and Davide Sangiorgi. 2017. Session types revisited. Inf. Comput. 256 (2017), 253–286. Google Scholar
Digital Library
- Romain Demangeon and Kohei Honda. 2012. Nested protocols in session types. In CONCUR (Lecture Notes in Computer Science), Vol. 7454. Springer, 272–286. Google Scholar
Digital Library
- Ian Fette and Alexey Melnikov. 2011. The WebSocket Protocol. RFC 6455. RFC Editor. 70 pages. http://www.rfc- editor.org/ rfc/rfc6455.txtGoogle Scholar
- Simon Fowler. 2016. An Erlang implementation of multiparty session actors. In ICE (EPTCS), Vol. 223. 36–50.Google Scholar
Cross Ref
- Simon Fowler, Sam Lindley, J. Garrett Morris, and Sára Decova. 2018. Exceptional Asynchronous Session Types: Session Types without Tiers (extended version). http://www.simonjf.com/writing/zap- extended.pdf . (2018).Google Scholar
- Simon J Gay and Vasco T Vasconcelos. 2010. Linear type theory for asynchronous session types. Journal of Functional Programming 20, 1 (2010), 19–50. Google Scholar
Digital Library
- Daniel Hillerström and Sam Lindley. 2016. Liberating effects with rows and handlers. In [email protected]. ACM, 15–27. Google Scholar
Digital Library
- Daniel Hillerström, Sam Lindley, Robert Atkey, and K. C. Sivaramakrishnan. 2017. Continuation passing style for effect handlers. In FSCD (LIPIcs), Vol. 84. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 18:1–18:19.Google Scholar
- Kohei Honda. 1993. Types for dyadic interaction. In CONCUR (Lecture Notes in Computer Science). Springer, 509–523. Google Scholar
Digital Library
- Kohei Honda, Vasco T Vasconcelos, and Makoto Kubo. 1998. Language primitives and type discipline for structured communication-based programming. In ESOP (Lecture Notes in Computer Science). Springer, 122–138. Google Scholar
Digital Library
- Kohei Honda, Nobuko Yoshida, and Marco Carbone. 2016. Multiparty asynchronous session types. Journal of the ACM (JACM) 63, 1 (2016), 9. Google Scholar
Digital Library
- Raymond Hu, Nobuko Yoshida, and Kohei Honda. 2008. Session-based distributed programming in Java. In ECOOP (Lecture Notes in Computer Science). Springer, 516–541. Google Scholar
Digital Library
- Thomas Bracht Laumann Jespersen, Philip Munksgaard, and Ken Friis Larsen. 2015. Session types for Rust. In WGP. ACM, 13–22. Google Scholar
Digital Library
- Naoki Kobayashi. 2002. Type systems for concurrent programs. In 10th Anniversary Colloquium of UNU/IIST (Lecture Notes in Computer Science), Vol. 2757. Springer, 439–453.Google Scholar
- Wen Kokke. 2018. rusty-variation : a library for deadlock-free session-typed communication in Rust. https://github.com/ wenkokke/rusty- variation . (2018).Google Scholar
- Sam Lindley and J. Garrett Morris. 2015. A semantics for propositions as sessions. In ESOP (Lecture Notes in Computer Science), Vol. 9032. Springer, 560–584.Google Scholar
- Sam Lindley and J Garrett Morris. 2016. Talking bananas: structural recursion for session types. In ICFP. ACM, 434–447. Google Scholar
Digital Library
- Sam Lindley and J Garrett Morris. 2017. Lightweight functional session types. In Behavioural Types: from Theory to Tools. River Publishers, 265–286.Google Scholar
- Nicholas D. Matsakis and Felix S. Klock II. 2014. The Rust language. In HILT. ACM, 103–104. Google Scholar
Digital Library
- Karl Mazurak, Jianzhou Zhao, and Steve Zdancewic. 2010. Lightweight linear types in System F°. In TLDI. ACM, 77–88. Google Scholar
Digital Library
- Robin Milner. 1999. Communicating and mobile systems: the pi calculus. Cambridge university press. Google Scholar
Digital Library
- Dimitris Mostrous and Vasco Thudichum Vasconcelos. 2014. Affine Sessions. In COORDINATION (Lecture Notes in Computer Science), Vol. 8459. Springer, 115–130. Google Scholar
Digital Library
- Rumyana Neykova and Nobuko Yoshida. 2014. Multiparty session actors. In COORDINATION (Lecture Notes in Computer Science), Vol. 8459. Springer, 131–146. Google Scholar
Digital Library
- Rumyana Neykova and Nobuko Yoshida. 2017a. Let it recover: multiparty protocol-induced recovery. In CC. ACM, 98–108. Google Scholar
Digital Library
- Rumyana Neykova and Nobuko Yoshida. 2017b. Multiparty session actors. Logical Methods in Computer Science 13, 1 (2017).Google Scholar
- Luca Padovani. 2017. A simple library implementation of binary sessions. Journal of Functional Programming 27 (2017), e4.Google Scholar
Cross Ref
- Jorge A Pérez, Luís Caires, Frank Pfenning, and Bernardo Toninho. 2012. Linear logical relations for session-based concurrency. In ESOP (Lecture Notes in Computer Science). Springer, 539–558.Google Scholar
- Gordon D. Plotkin and Matija Pretnar. 2013. Handling algebraic effects. Logical Methods in Computer Science 9, 4 (2013).Google Scholar
- Didier Rémy. 1994. Type inference for records in a natural extension of ML. In Theoretical Aspects Of Object-Oriented Programming, Carl A. Gunter and John C. Mitchell (Eds.). MIT Press, Cambridge, MA, 67–95.Google Scholar
- Alceste Scalas, Ornela Dardha, Raymond Hu, and Nobuko Yoshida. 2017. A linear decomposition of multiparty sessions for safe distributed programming. In ECOOP (LIPIcs), Vol. 74. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 24:1–24:31.Google Scholar
- Alceste Scalas and Nobuko Yoshida. 2016. Lightweight session programming in scala. In ECOOP (LIPIcs), Vol. 56. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 21:1–21:28.Google Scholar
- Jérôme Vouillon. 2008. Lwt: a cooperative thread library. In ML. ACM, 3–12. Google Scholar
Digital Library
- Philip Wadler. 2014. Propositions as sessions. Journal of Functional Programming 24, 2-3 (2014), 384–418.Google Scholar
Cross Ref
Index Terms
Exceptional asynchronous session types: session types without tiers
Recommendations
Multiparty Asynchronous Session Types
Communication is a central elements in software development. As a potential typed foundation for structured communication-centered programming, session types have been studied over the past decade for a wide range of process calculi and programming ...
Multiparty asynchronous session types
POPL '08: Proceedings of the 35th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languagesCommunication is becoming one of the central elements in software development. As a potential typed foundation for structured communication-centred programming, session types have been studied over the last decade for a wide range of process calculi and ...
Multiparty asynchronous session types
POPL '08Communication is becoming one of the central elements in software development. As a potential typed foundation for structured communication-centred programming, session types have been studied over the last decade for a wide range of process calculi and ...






Comments