Linear Haskell: practical linearity in a higher-order polymorphic language
arXiv:1710.09756 · doi:10.1145/3158093
Abstract
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.
References in corpus (1)
Cited by in corpus (18)
- Linear Dependent Type Theory for Quantum Programming Languages
- A Survey on Parallelism and Determinism
- Soundly Handling Linearity
- Deriving Distributive Laws for Graded Linear Types
- Linearly Qualified Types: Generic inference for capabilities and uniqueness
- Replicate, Reuse, Repeat: Capturing Non-Linear Communication via Session Types and Graded Modal Types
- Efficient CHAD
- Effects and Coeffects in Call-By-Push-Value (Extended Version)
- Concurrent Typestate-Oriented Programming in Java
- Parameterized Algebraic Protocols
- Prioritise the Best Variation
- Linear Contextual Metaprogramming and Session Types
- Complete the Cycle: Reachability Types with Expressive Cyclic References (Extended Version)
- Typed Design Patterns for the Functional Era
- Deriving Theorems in Implicational Linear Logic, Declaratively
- Kind Inference for the FreeST Programming Language
- Linear effects, exceptions, and resource safety: a Curry-Howard correspondence for destructors
- Thread and Memory-Safe Programming with CLASS