Law and Order for Typestate with Borrowing

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Saffrich, Hannes, Nishida, Yuki, Thiemann, Peter
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866916411487551488
author Saffrich, Hannes
Nishida, Yuki
Thiemann, Peter
author_facet Saffrich, Hannes
Nishida, Yuki
Thiemann, Peter
contents Typestate systems are notoriously complex as they require sophisticated machinery for tracking aliasing. We propose a new, transition-oriented foundation for typestate in the setting of impure functional programming. Our approach relies on ordered types for simple alias tracking and its formalization draws on work on bunched implications. Yet, we support a flexible notion of borrowing in the presence of typestate. Our core calculus comes with a notion of resource types indexed by an ordered partial monoid that models abstract state transitions. We prove syntactic type soundness with respect to a resource-instrumented semantics. We give an algorithmic version of our type system and prove its soundness. Algorithmic typing facilitates a simple surface language that does not expose tedious details of ordered types. We implemented a typechecker for the surface language along with an interpreter for the core language.
format Preprint
id arxiv_https___arxiv_org_abs_2408_14031
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Law and Order for Typestate with Borrowing
Saffrich, Hannes
Nishida, Yuki
Thiemann, Peter
Programming Languages
Typestate systems are notoriously complex as they require sophisticated machinery for tracking aliasing. We propose a new, transition-oriented foundation for typestate in the setting of impure functional programming. Our approach relies on ordered types for simple alias tracking and its formalization draws on work on bunched implications. Yet, we support a flexible notion of borrowing in the presence of typestate. Our core calculus comes with a notion of resource types indexed by an ordered partial monoid that models abstract state transitions. We prove syntactic type soundness with respect to a resource-instrumented semantics. We give an algorithmic version of our type system and prove its soundness. Algorithmic typing facilitates a simple surface language that does not expose tedious details of ordered types. We implemented a typechecker for the surface language along with an interpreter for the core language.
title Law and Order for Typestate with Borrowing
topic Programming Languages
url https://arxiv.org/abs/2408.14031