Linear Type Systems
Linear types constrain how resources are used. Session types extend this reasoning to communication, where an endpoint’s type changes as messages are sent or received.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 3
- Reading time
- 1 min
In this article3 chapters
Contexts represent resource budgets
In a linear context a binding must be used exactly once. An affine discipline permits discarding it as well, while retaining the restriction against arbitrary duplication. For a pair constructor, the context can be split into disjoint resources for the two components. If both components could use the same linear binding, a resource such as an exclusive token would be duplicated. Unrestricted bindings can have an explicit separate treatment, often connected to an exponential modality in linear logic.
Ownership and borrowing make responsibility and temporary access explicit. Separating conjunction is a complementary way to express when two requirements refer to disjoint heap resources.
A channel endpoint carries a protocol
Consider the session type at one endpoint and its dual.
\[ !\mathrm{Int}.\,?\mathrm{Bool}.\,\mathrm{end} \quad\longleftrightarrow\quad ?\mathrm{Int}.\,!\mathrm{Bool}.\,\mathrm{end}. \]
The first endpoint sends an integer, receives a Boolean and closes. The other performs the dual sequence. Sending consumes the old endpoint state and yields a continuation endpoint for receiving. Reusing the old state would allow a second, protocol-inconsistent send. The dual peer can also be checked locally. A global progress guarantee for programs using many sessions needs further conditions, since each endpoint can be well typed while dependencies between different channels form a cycle.
From typing to runtime obligations
Affine ownership can justify deterministic cleanup of a resource when the language specifies a cleanup path. Temporary borrows require rules about aliasing and lifetime. Similarly, typing an effect handler that resumes many times depends on what resources the continuation captures. These connections lead to algebraic effects, local resource assertions in separation logic, and verified inter-thread protocols in concurrent separation logic.[1][2]