In
type theory
In mathematics, logic, and computer science, a type theory is the formal system, formal presentation of a specific type system, and in general type theory is the academic study of type systems. Some type theories serve as alternatives to set theor ...
, session types are used to ensure correctness in
concurrent
Concurrent means happening at the same time. Concurrency, concurrent, or concurrence may refer to:
Law
* Concurrence, in jurisprudence, the need to prove both ''actus reus'' and ''mens rea''
* Concurring opinion (also called a "concurrence"), a ...
programs. They guarantee that messages sent and received between concurrent programs are in the expected order and of the expected
type
Type may refer to:
Science and technology Computing
* Typing, producing text via a keyboard, typewriter, etc.
* Data type, collection of values used for computations.
* File type
* TYPE (DOS command), a command to display contents of a file.
* Ty ...
.
Session type systems have been adapted for both
channel and
actor
An actor or actress is a person who portrays a character in a performance. The actor performs "in the flesh" in the traditional medium of the theatre or in modern media such as film, radio, and television. The analogous Greek term is (), l ...
systems.
Session types are used to ensure desirable properties in
concurrent
Concurrent means happening at the same time. Concurrency, concurrent, or concurrence may refer to:
Law
* Concurrence, in jurisprudence, the need to prove both ''actus reus'' and ''mens rea''
* Concurring opinion (also called a "concurrence"), a ...
and
distributed Distribution may refer to:
Mathematics
*Distribution (mathematics), generalized functions used to formulate solutions of partial differential equations
*Probability distribution, the probability of a particular value or value range of a varia ...
systems, i.e. absence of communication errors or deadlocks, and protocol conformance.
Binary versus Multiparty Session Types
Interaction between two processes can be checked using ''binary'' session types, while interactions between more than two processes can be checked using ''multiparty'' session types. In multiparty session types interactions between all participants are described using a ''global type'', which is then projected into ''local types'' that describe communication from the local view of each participant. Importantly, the global type encodes the sequencing information of the communication, which would be lost if we were to use binary session types to encode the same communication.
Formal definition of binary Session Types
Binary session types can be described using send operations (
), receive operations (
), branches (
), selections (
), recursion (
) and termination (
).
For example,
represents a session type
which first sends a
boolean (
), then receives an
integer
An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
(
) before finally terminating (
).
Implementations
Session types have been adapted for several existing programming languages, including:
* lchannels (
Scala)
* Effpi (Scala)
* STMonitor (Scala)
* EnsembleS
* Session-types (
Rust
Rust is an iron oxide, a usually reddish-brown oxide formed by the reaction of iron and oxygen in the catalytic presence of water or air moisture. Rust consists of hydrous iron(III) oxides (Fe2O3·nH2O) and iron(III) oxide-hydroxide (FeO(OH), ...
)
* sesh (Rust)
* Session Actors (
Python)
* Monitored Session Erlang (
Erlang)
* FuSe (
OCaml
OCaml ( , formerly Objective Caml) is a general-purpose, multi-paradigm programming language which extends the Caml dialect of ML with object-oriented features. OCaml was created in 1996 by Xavier Leroy, Jérôme Vouillon, Damien Doligez, D ...
)
* session-ocaml (OCaml)
* Priority Sesh (
Haskell
Haskell () is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research and industrial applications, Haskell has pioneered a number of programming lan ...
)
* Java Typestate Checker (
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
)
References
Concurrency (computer science)
Type theory
Type systems
{{Comp-sci-stub