Linear effects, exceptions, and resource safety: a Curry-Howard correspondence for destructors

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Congard, Sidney, Munch-Maccagnoni, Guillaume, Douence, Rémi
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866918458175782912
author Congard, Sidney
Munch-Maccagnoni, Guillaume
Douence, Rémi
author_facet Congard, Sidney
Munch-Maccagnoni, Guillaume
Douence, Rémi
contents 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 $T(- \oplus E)$ 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 $\mathbf{new}$ and $\mathbf{delete}$. 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 $δ: A\rightarrow TI$ in the slice category over $TI$. 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.
format Preprint
id arxiv_https___arxiv_org_abs_2510_23517
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Linear effects, exceptions, and resource safety: a Curry-Howard correspondence for destructors
Congard, Sidney
Munch-Maccagnoni, Guillaume
Douence, Rémi
Programming Languages
Logic in Computer Science
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 $T(- \oplus E)$ 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 $\mathbf{new}$ and $\mathbf{delete}$. 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 $δ: A\rightarrow TI$ in the slice category over $TI$. 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.
title Linear effects, exceptions, and resource safety: a Curry-Howard correspondence for destructors
topic Programming Languages
Logic in Computer Science
url https://arxiv.org/abs/2510.23517