Lightweight Session Programming in Scala

Authors Alceste Scalas, Nobuko Yoshida

Thumbnail PDF


  • Filesize: 1.24 MB
  • 28 pages

Document Identifiers

Author Details

Alceste Scalas
Nobuko Yoshida

Cite AsGet BibTex

Alceste Scalas and Nobuko Yoshida. Lightweight Session Programming in Scala. In 30th European Conference on Object-Oriented Programming (ECOOP 2016). Leibniz International Proceedings in Informatics (LIPIcs), Volume 56, pp. 21:1-21:28, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2016)


Designing, developing and maintaining concurrent applications is an error-prone and time-consuming task; most difficulties arise because compilers are usually unable to check whether the inputs/outputs performed by a program at runtime will adhere to a given protocol specification. To address this problem, we propose lightweight session programming in Scala: we leverage the native features of the Scala type system and standard library, to introduce (1) a representation of session types as Scala types, and (2) a library, called lchannels, with a convenient API for session-based programming, supporting local and distributed communication. We generalise the idea of Continuation-Passing Style Protocols (CPSPs), studying their formal relationship with session types. We illustrate how session programming can be carried over in Scala: how to formalise a communication protocol, and represent it using Scala classes and lchannels, letting the compiler help spotting protocol violations. We attest the practicality of our approach with a complex use case, and evaluate the performance of lchannels with a series of benchmarks.
  • session types
  • Scala
  • concurrency


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Karim Ali, Marianna Rapoport, Ondřej Lhoták, Julian Dolby, and Frank Tip. Constructing call graphs of Scala programs. In ECOOP, 2014. URL:
  2. Nada Amin, Tiark Rompf, and Martin Odersky. Foundations of path-dependent types. In OOPSLA, 2014. URL:
  3. Stephanie Balzer and Frank Pfenning. Objects as session-typed processes. In AGERE!, 2015. URL:
  4. Hendrik Pieter Barendregt. The Lambda Calculus, Its Syntax and Semantics. North Holland, 1985. Google Scholar
  5. Luís Caires and Frank Pfenning. Session types as intuitionistic linear propositions. In CONCUR, 2010. URL:
  6. Ornela Dardha. Recursive session types revisited. In BEAT, 2014. URL:
  7. Ornela Dardha. Type Systems for Distributed Programs: Components and Sessions. Phd thesis, Università degli studi di Bologna, May 2014. Google Scholar
  8. Ornela Dardha, Elena Giachino, and Davide Sangiorgi. Session types revisited. In PPDP, 2012. URL:
  9. Romain Demangeon and Kohei Honda. Full abstraction in a subtyped pi-calculus with linear types. In CONCUR, 2011. Google Scholar
  10. Edsger W Dijkstra. Cooperating sequential processes. Springer, 1965. Google Scholar
  11. Juliana Franco and Vasco Thudichum Vasconcelos. A concurrent programming language with refined session types. In SEFM, 2013. URL:
  12. Simon Gay and Malcolm Hole. Types and subtypes for client-server interactions. In ESOP. Springer Berlin Heidelberg, 1999. URL:
  13. Simon Gay and Malcolm Hole. Subtyping for session types in the pi calculus. Acta Informatica, 2005. URL:
  14. Simon J. Gay and Vasco T. Vasconcelos. Linear type theory for asynchronous session types. J. Funct. Program., 20(1), January 2010. URL:
  15. Philipp Haller and Martin Odersky. Capabilities for uniqueness and borrowing. In ECOOP, 2010. Google Scholar
  16. Philipp Haller, Aleksandar Prokopec, Heather Miller, Viktor Klang, Roland Kuhn, and Vojin Jovanovic. Futures and Promises. URL:
  17. Jiansen He, Philip Wadler, and Philip Trinder. Typecasting actors: From Akka to TAkka. In SCALA'14, 2014. URL:
  18. Kohei Honda. Types for dyadic interaction. In CONCUR, 1993. URL:
  19. Kohei Honda, Vasco Thudichum Vasconcelos, and Makoto Kubo. Language primitives and type discipline for structured communication-based programming. In ESOP, 1998. URL:
  20. Kohei Honda, Nobuko Yoshida, and Marco Carbone. Multiparty asynchronous session types. In POPL, 2008. URL:
  21. Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, and Kohei Honda. Type-safe eventful sessions in Java. In ECOOP, 2010. URL:
  22. Raymond Hu and Nobuko Yoshida. Hybrid session verification through endpoint API generation. In FASE, 2016. Google Scholar
  23. Raymond Hu, Nobuko Yoshida, and Kohei Honda. Session-based distributed programming in Java. In ECOOP, 2008. URL:
  24. Shams M. Imam and Vivek Sarkar. Savina - an actor benchmark suite: Enabling empirical evaluation of actor libraries. In Proceedings of the 4th International Workshop on Programming Based on Actors Agents & Decentralized Control, AGERE!, 2014. URL:
  25. Thomas Bracht Laumann Jespersen, Philip Munksgaard, and Ken Friis Larsen. Session types for rust. In Proceedings of the 11th ACM SIGPLAN Workshop on Generic Programming, WGP, 2015. URL:
  26. Roland Kuhn. Project G\aalbma, actors vs types, 2015. URL:
  27. Lightbend, Inc. Actor paths, 2016. URL:
  28. Lightbend, Inc. The Akka toolkit and runtime, 2016. URL:
  29. Lightbend, Inc. Akka Typed, 2016. URL:
  30. Lightbend, Inc. The Scala IDE, 2016. URL:
  31. Robin Milner, Joachim Parrow, and David Walker. A calculus of mobile processes. Inf. &Comput., 1992. URL:
  32. Matthias Neubauer and Peter Thiemann. An implementation of session types. In PADL, 2004. URL:
  33. Luca Padovani. A Simple Library Implementation of Binary Sessions., 2015.
  34. Riccardo Pucella and Jesse A. Tov. Haskell session types with (almost) no class. In Haskell, 2008. URL:
  35. Tiark Rompf and Nada Amin. From F to DOT: Type soundness proofs with definitional interpreters. Technical report, Purdue University and EPFL, 2015. Unpublished. URL:
  36. Davide Sangiorgi and David Walker. The Pi-Calculus: A Theory of Mobile Processes. Cambridge University Press, 2003. Google Scholar
  37. K. C. Sivaramakrishnan, Karthik Nagaraj, Lukasz Ziarek, and Patrick Eugster. Efficient session type guided distributed interaction. In COORDINATION, 2010. URL:
  38. K. C. Sivaramakrishnan, Mohammad Qudeisat, Lukasz Ziarek, Karthik Nagaraj, and Patrick Eugster. Efficient sessions. Sci. Comput. Program., 78(2), 2013. URL:
  39. Kaku Takeuchi, Kohei Honda, and Makoto Kubo. An interaction-based language and its typing system. In PARLE, 1994. URL:
  40. Bernardo Toninho, Luís Caires, and Frank Pfenning. Higher-order processes, functions, and sessions: a monadic integration. In ESOP, 2013. URL:
  41. Matías Toro and Éric Tanter. Customizable gradual polymorphic effects for Scala. In OOPSLA, 2015. URL:
  42. Vasco T. Vasconcelos. Fundamentals of session types. Inf. &Comput., 217, 2012. URL:
  43. Philip Wadler. Propositions as sessions. In ICFP, 2012. URL:
  44. Nobuko Yoshida, Raymond Hu, Rumyana Neykova, and Nicholas Ng. The scribble protocol language. In TGC, 2013. URL: