5 research outputs found
Polymorphic Typestate for Session Types
Session types provide a principled approach to typed communication protocols
that guarantee type safety and protocol fidelity. Formalizations of
session-typed communication are typically based on process calculi, concurrent
lambda calculi, or linear logic. An alternative model based on
context-sensitive typing and typestate has not received much attention due to
its apparent restrictions. However, this model is attractive because it does
not force programmers into particular patterns like continuation-passing style
or channel-passing style, but rather enables them to treat communication
channels like mutable variables. Polymorphic typestate is the key that enables
a full treatment of session-typed communication. Previous work in this
direction was hampered by its setting in a simply-typed lambda calculus. We
show that higher-order polymorphism and existential types enable us to lift the
restrictions imposed by the previous work, thus bringing the expressivity of
the typestate-based approach on par with the competition. On this basis, we
define PolyVGR, the system of polymorphic typestate for session types,
establish its basic metatheory, type preservation and progress, and present a
prototype implementation.Comment: 29 pages. Short version appears in PPDP 202
Relating Functional and Imperative Session Types
Imperative session types provide an imperative interface to session-typed
communication. In such an interface, channel references are first-class objects
with operations that change the typestate of the channel. Compared to
functional session type APIs, the program structure is simpler at the surface,
but typestate is required to model the current state of communication
throughout.
Following an early work that explored the imperative approach, a significant
body of work on session types has neglected the imperative approach and opts
for a functional approach that uses linear types to manage channel references
soundly. We demonstrate that the functional approach subsumes the early work on
imperative session types by exhibiting a typing and semantics preserving
translation into a system of linear functional session types.
We further show that the untyped backwards translation from the functional to
the imperative calculus is semantics preserving. We restrict the type system of
the functional calculus such that the backwards translation becomes type
preserving. Thus, we precisely capture the difference in expressiveness of the
two calculi and conclude that the lack of expressiveness in the imperative
calculus is largely due to restrictions imposed by its type system.Comment: 39 pages, insubmissio
Kindly Bent to Free Us
Systems programming often requires the manipulation of resources like file
handles, network connections, or dynamically allocated memory. Programmers need
to follow certain protocols to handle these resources correctly. Violating
these protocols causes bugs ranging from type mismatches over data races to
use-after-free errors and memory leaks. These bugs often lead to security
vulnerabilities.
While statically typed programming languages guarantee type soundness and
memory safety by design, most of them do not address issues arising from
improper handling of resources. An important step towards handling resources is
the adoption of linear and affine types that enforce single-threaded resource
usage. However, the few languages supporting such types require heavy type
annotations.
We present Affe, an extension of ML that manages linearity and affinity
properties using kinds and constrained types. In addition Affe supports the
exclusive and shared borrowing of affine resources, inspired by features of
Rust. Moreover, Affe retains the defining features of the ML family: it is an
impure, strict, functional expression language with complete principal type
inference and type abstraction. Affe does not require any linearity annotations
in expressions and supports common functional programming idioms.Comment: ICFP 202
Relating Functional and Imperative Session Types
Imperative session types provide an imperative interface to session-typed
communication. In such an interface, channel references are first-class objects
with operations that change the typestate of the channel. Compared to
functional session type APIs, the program structure is simpler at the surface,
but typestate is required to model the current state of communication
throughout. Following an early work that explored the imperative approach, a
significant body of work on session types has neglected the imperative approach
and opts for a functional approach that uses linear types to manage channel
references soundly. We demonstrate that the functional approach subsumes the
early work on imperative session types by exhibiting a typing and semantics
preserving translation into a system of linear functional session types. We
further show that the untyped backwards translation from the functional to the
imperative calculus is semantics preserving. We restrict the type system of the
functional calculus such that the backwards translation becomes type
preserving. Thus, we precisely capture the difference in expressiveness of the
two calculi and conclude that the lack of expressiveness in the imperative
calculus is largely due to restrictions imposed by its type system
Kindly bent to free us
International audienceSystems programming often requires the manipulation of resources like file handles, network connections, or dynamically allocated memory. Programmers need to follow certain protocols to handle these resources correctly. Violating these protocols causes bugs ranging from type mismatches over data races to use-after-free errors and memory leaks. These bugs often lead to security vulnerabilities. While statically typed programming languages guarantee type soundness and memory safety by design, most of them do not address issues arising from improper handling of resources. An important step towards handling resources is the adoption of linear and affine types that enforce single-threaded resource usage. However, the few languages supporting such types require heavy type annotations. We present Affe, an extension of ML that manages linearity and affinity properties using kinds and constrained types. In addition Affe supports the exclusive and shared borrowing of affine resources, inspired by features of Rust. Moreover, Affe retains the defining features of the ML family: it is an impure, strict, functional expression language with complete principal type inference and type abstraction. Affe does not require any linearity annotations in expressions and supports common functional programming idioms