Compiling Morphisms of Algebraic Data Types - Archive ouverte HAL
Pré-Publication, Document De Travail Année : 2024

Compiling Morphisms of Algebraic Data Types

Résumé

Now integrated in mainstream languages, Algebraic Data Types (ADTs) have established themselves as a nice way to reason about data structures and their manipulation using pattern matching. However, their use in low-level programming remains limited despite efforts, notably from the Rust community. Recently, Baudon et al. [2023] propose to let programmers express the precise memory layout of a given Algebraic Data Type, while still enjoying high-level programming constructs. Their compilation procedure covers efficient pattern matching, but leaves out constructors and struggles with arbitrarily mangled memory layouts. So far, the literature on ADT compilation rarely mentions constructors, which are indeed a non-issue on simple memory layouts. However, when data pieces are broken and scattered in memory, this task becomes particularly challenging. Even simple accessors might require constructing new values. This is the case for many low-level representations such as network packets, instruction sets, database data-structures, or aggressively packed representations. In this article, we go one step further, by enabling optimized compilation of any morphisms between ADTs for arbitrary mangled memory representations. We also provide full synthesis of bijections between memory representations of the same type. We subsume existing compilation algorithms, and extend them to emit CFG-style programs with explicit memory allocation and full support for recursive types.
Fichier principal
Vignette du fichier
main.pdf (805.28 Ko) Télécharger le fichier
Origine Fichiers produits par l'(les) auteur(s)

Dates et versions

hal-04601882 , version 1 (05-06-2024)

Identifiants

  • HAL Id : hal-04601882 , version 1

Citer

Thaïs Baudon, Gabriel Radanne, Laure Gonnord. Compiling Morphisms of Algebraic Data Types. 2024. ⟨hal-04601882⟩
143 Consultations
116 Téléchargements

Partager

More