In
type theory
In mathematics and theoretical computer science, a type theory is the formal presentation of a specific type system. Type theory is the academic study of type systems.
Some type theories serve as alternatives to set theory as a foundation of ...
, 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.
* ...
.
Session type systems have been adapted for both
channel
Channel, channels, channeling, etc., may refer to:
Geography
* Channel (geography), a landform consisting of the outline (banks) of the path of a narrow body of water.
Australia
* Channel Country, region of outback Australia in Queensland and pa ...
and
actor
An actor (masculine/gender-neutral), or actress (feminine), is a person who portrays a character in a production. The actor performs "in the flesh" in the traditional medium of the theatre or in modern media such as film, radio, and television. ...
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
Any kind of logic, function, expression, or theory based on the work of George Boole is considered Boolean.
Related to this, "Boolean" may refer to:
* Boolean data type, a form of data with only two possible values (usually "true" and "false" ...
(
), then receives an
integer
An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
(
) 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
Python may refer to:
Snakes
* Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia
** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia
* Python (mythology), a mythical serpent
Computing
* Python (prog ...
)
* Monitored Session Erlang (
Erlang)
* FuSe (
OCaml
OCaml ( , formerly Objective Caml) is a General-purpose programming language, general-purpose, High-level programming language, high-level, Comparison of multi-paradigm programming languages, multi-paradigm programming language which extends the ...
)
* 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 pioneered several programming language ...
)
* Java Typestate Checker (
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
)
* Swift Sessions (
Swift
Swift or SWIFT most commonly refers to:
* SWIFT, an international organization facilitating transactions between banks
** SWIFT code
* Swift (programming language)
* Swift (bird), a family of birds
It may also refer to:
Organizations
* SWIF ...
)
References
Concurrency (computer science)
Type theory
Type systems
{{Comp-sci-stub