1,185 research outputs found
Linear Haskell: practical linearity in a higher-order polymorphic language
Linear type systems have a long and storied history, but not a clear path
forward to integrate with existing languages such as OCaml or Haskell. In this
paper, we study a linear type system designed with two crucial properties in
mind: backwards-compatibility and code reuse across linear and non-linear users
of a library. Only then can the benefits of linear types permeate conventional
functional programming. Rather than bifurcate types into linear and non-linear
counterparts, we instead attach linearity to function arrows. Linear functions
can receive inputs from linearly-bound values, but can also operate over
unrestricted, regular values.
To demonstrate the efficacy of our linear type system - both how easy it can
be integrated in an existing language implementation and how streamlined it
makes it to write programs with linear types - we implemented our type system
in GHC, the leading Haskell compiler, and demonstrate two kinds of applications
of linear types: mutable data with pure interfaces; and enforcing protocols in
I/O-performing functions
Contextual Linear Types for Differential Privacy
Language support for differentially-private programming is both crucial and
delicate. While elaborate program logics can be very expressive, type-system
based approaches using linear types tend to be more lightweight and amenable to
automatic checking and inference, and in particular in the presence of
higher-order programming. Since the seminal design of Fuzz, which is restricted
to -differential privacy, a lot of effort has been made to support
more advanced variants of differential privacy, like
(,)-differential privacy. However, supporting these advanced
privacy variants while also supporting higher-order programming in full has
been proven to be challenging. We present Jazz, a language and type system
which uses linear types and latent contextual effects to support both advanced
variants of differential privacy and higher-order programming. Even when
avoiding advanced variants and higher-order programming, our system achieves
higher precision than prior work for a large class of programming patterns. We
formalize the core of the Jazz language, prove it sound for privacy via a
logical relation for metric preservation, and illustrate its expressive power
through a number of case studies drawn from the recent differential privacy
literature.Comment: Journal revisio
NumLin: Linear Types for Linear Algebra (Artifact)
The artifact package includes a Debian 9.7 Stretch VirtualBox virtual machine on which is the implementation of NumLin and the required OCaml platform and packages
Linear Types, Protocols, and Processes in Classical F°
Session types and typestate both promise a type system that can reason about protocol
adherence. The complexity budgets of most programming languages, however, do not
allow for new forms of types aimed at specific problem domains--even domains as broad
as these.
Classical F◦ --read F-pop --is a typed λ-calculus based on classical (i.e., full) linear
logic, wherein session types arise naturally from the interaction between the usual sums,
products, and implications of linear logic and a simple process model, with the dualizing
negation of classical logic naturally accounting for how a protocol is seen by each of a
channel\u27s endpoints. Classical F◦ expressions evaluate to processes, reminiscent of those
in the π-calculus, that communicate over channels, but source expressions, rather than
including processes and channels, employ only two novel control operators that account
for process creation and communication.
F◦ is introduced by way of its intuitionistic fragment, which even on its own can account
for typestate: the combination of linearity and polymorphism leads to natural encodings
of many programmer-specified protocols. In fact, any protocol expressible as a regular
language can be encoded in an intuitionistic F◦ type. F◦ distinguishes between linear
and unrestricted types by using kinds together with a notion of subkinding, avoiding
the pitfalls of approaches based on type qualifiers or modalities; kinds are related by a
subkinding order that allows unrestricted types to be treated as though they were linear.
Soundness for intuitionistic and classical F◦ is proved both in the standard operational
sense of preservation and progress and for an augmented semantics that shows more
directly that the expected properties of linearity are preserved. This establishes the absence
of deadlocks in closed, well-typed F◦ programs; it also guarantees that such programs will
not leak processes as long as their result types are unrestricted
Linear/non-Linear Types For Embedded Domain-Specific Languages
Domain-specific languages are often embedded inside of general-purpose host languages so that the embedded language can take advantage of host-language data structures, libraries, and tools. However, when the domain-specific language uses linear types, existing techniques for embedded languages fall short. Linear type systems, which have applications in a wide variety of programming domains including mutable state, I/O, concurrency, and quantum computing, can manipulate embedded non-linear data via the linear type !σ. However, prior work has not been able to produce linear embedded languages that have full and easy access to host-language data, libraries, and tools.
This dissertation proposes a new perspective on linear, embedded, domain-specific languages derived from the linear/non-linear (LNL) interpretation of linear logic. The LNL model consists of two distinct fragments---one with linear types and another with non-linear types---and provides a simple categorical interface between the two. This dissertation identifies the linear fragment with the linear embedded language and the non-linear fragment with the general-purpose host language.
The effectiveness of this framework is illustrated via a number of examples, implemented in a variety of host languages. In Haskell, linear domain-specific languages using mutable state and concurrency can take advantage of the monad that arises from the LNL model. In Coq, the QWIRE quantum circuit language uses linearity to enforce the no-cloning axiom of quantum mechanics. In homotopy type theory, quantum transformations can be encoded as higher inductive types to simplify the presentation of a quantum equational theory. These examples serve as case studies that prove linear/non-linear type theory is a natural and expressive interface in which to embed linear domain-specific languages
Modular Inference of Linear Types for Multiplicity-Annotated Arrows
Bernardy et al. [2018] proposed a linear type system as a
core type system of Linear Haskell. In the system, linearity is represented by
annotated arrow types , where denotes the multiplicity of the
argument. Thanks to this representation, existing non-linear code typechecks as
it is, and newly written linear code can be used with existing non-linear code
in many cases. However, little is known about the type inference of
. Although the Linear Haskell implementation is equipped with
type inference, its algorithm has not been formalized, and the implementation
often fails to infer principal types, especially for higher-order functions. In
this paper, based on OutsideIn(X) [Vytiniotis et al., 2011], we propose an
inference system for a rank 1 qualified-typed variant of , which
infers principal types. A technical challenge in this new setting is to deal
with ambiguous types inferred by naive qualified typing. We address this
ambiguity issue through quantifier elimination and demonstrate the
effectiveness of the approach with examples.Comment: The full version of our paper to appear in ESOP 202
- …