Reference. Resource Polymorphism

We present a resource-management model for ML-style programming languages, designed to be compatible with the OCaml philosophy and runtime model. This is a proposal to extend the OCaml language with destructors, move semantics, and resource polymorphism, to improve its safety, efficiency, interoperability, and expressiveness. It builds on the ownership-and-borrowing models of systems programming languages (Cyclone, C++11, Rust) and on linear types in functional programming (Linear Lisp, Clean, Alms). It continues a synthesis of resources from systems programming and resources in linear logic initiated by Baker. It is a combination of many known and some new ideas. On the novel side, it highlights the good mathematical structure of Stroustrup’s “Resource acquisition is initialisation” (RAII) idiom for resource management based on destructors, a notion sometimes confused with finalizers, and builds on it a notion of resource polymorphism, inspired by polarisation in proof theory, that mixes C++‘s RAII and a tracing garbage collector (GC). The proposal targets a new spot in the design space, with an automatic and predictable resource-management model, at the same time based on lightweight and expressive language abstractions. It is backwards-compatible: current code is expected to run with the same performance, the new abstractions fully combine with the current ones, and it supports a resource-polymorphic extension of libraries. It does so with only a few additions to the runtime, and it integrates with the current GC implementation. It is also compatible with the upcoming multicore extension, and suggests that the Rust model for eliminating data-races applies. Interesting questions arise for a safe and practical type system, many of which have already been thoroughly investigated in the languages and prototypes Cyclone, Rust, and Alms.

Cite

Cite as @munchmaccagnoni-2018-resource (helia, typst) · \cite{munchmaccagnoni-2018-resource} (LaTeX)
BibTeX
bibtex · 8 lines
@misc{munchmaccagnoni-2018-resource,
  author = {Guillaume Munch-Maccagnoni},
  title = {Resource Polymorphism},
  year = {2018},
  month = {3},
  eprint = {1803.02796},
  archiveprefix = {arXiv}
}
hayagriva YAML (typst)
yaml · 7 lines
munchmaccagnoni-2018-resource:
  type: misc
  title: Resource Polymorphism
  author: Munch-Maccagnoni, Guillaume
  date: 2018-03
  serial-number:
    arxiv: '1803.02796'
Cited by (1)

Linear Effects, Exceptions, and Resource Safety: A Curry-Howard Correspondence for Destructors congard-2026-linear

We analyse the problem of combining linearity, effects, and exceptions, in abstract models of programming languages, as the issue of providing some kind of strength for a monad 𝑇(−⊕𝐸) in a linear setting. We consider in particular for T the allocation monad, which we introduce to model and study resource-safety properties. We apply these results to a series of two linear effectful calculi for which we establish their resource-safety properties. The first calculus is a linear (optionally ordered) call-by-push-value language with two allocation effects 𝐧𝐞𝐰 and 𝐝𝐞𝐥𝐞𝐭𝐞. The resource-safety properties follow from the linear and ordered character of the typing rules. We then integrate exceptions with linearity and effects by adjoining default destruction actions to types, as inspired by C++/Rust destructors. We see destructors as objects 𝛿:𝐴→𝑇𝐼 in the slice category over 𝑇𝐼. This construction gives rise to a second calculus, the resource call-by-push-value, featuring exceptions and destructors, and whose weakening and exchange rules perform side-effects. It is therefore affine at the level of types but ordered at the level of derivations. As in C++ and Rust, a “move” operation—the side-effecting exchange rule—is necessary for releasing resources in random order, as opposed to LIFO order.
PDF · DOI · arXiv · pldb
Cites 68 works (4 here)
With notes (4)

A theory of effects and resources: adjunction models and polarised calculi curien-2016-a

DOI · pldb

Formulae-as-types for an involutive negation munchmaccagnoni-2014-formulae

DOI

Call-By-Push-Value: A Functional/Imperative Synthesis levy-2003-callbypushvalue

DOI

Linear logic girard_linear_1987

The familiar connective of negation is broken into two operations: linear negation which is the purely negative part of negation and the modality “of course” which has the meaning of a reaffirmation. Following this basic discovery, a completely new approach to the whole area between constructive logics and programmation is initiated.
DOI
External (64)
munchmaccagnoni-2018-resource reference entries/refs/munchmaccagnoni-2018-resource/munchmaccagnoni-2018-resource.hel