Programming with Composable Recursive Patterns and Transformations
Luyu Cheng, Florent Ferrari, Michael D. Adams, Lionel Parreaux
Key points
From the paper's conclusion- We also demonstrate the practicality of CRPTs with an implementation in the MLscript programming language, which we evaluate against comparable existing approaches on several examples.
Abstract
Data processing using traditional pattern matching syntax and direct recursive functions is straightforward to write but becomes awkward in ambiguous (i.e., nondeterministic) cases: when programmers wish to avoid backtracking, they often end up having to write complicated code that sacrifices clarity and modularity. However, when the tree language being matched is regular, better solutions are possible. This paper presents composable recursive patterns and transformations (CRPTs), a new programming language feature designed to tackle this problem. CRPTs resemble and act like recursive type definitions in a structurally-typed language, which can be composed seamlessly to type check programs, but they also have a runtime component: they are compiled into backtracking-free code that recognizes and transforms their input in linear time. They serve both to validate existing data—for example, when checking structured JSON input against a CRPT that acts as a data schema—and to transform data in a type-safe and efficient manner. We formalize the dynamic semantics of CRPTs, a static type system for them, and a translation into efficient code that executes in time linear in the size of the input and polynomial in the size of the pattern. We also demonstrate the practicality of CRPTs with an implementation in the MLscript programming language, which we evaluate against comparable existing approaches on several examples.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Functional Programming with Hypergraph TransformationarXiv · 2026
- Type-Checking for Pattern-Based Tree TransformationsarXiv · 2026
- Filtr: Compiling Bioinformatics RecurrencesProceedings of the ACM on Programming Languages · 2026
- Beyond Nominality: Faster Rapid Type Analysis in the Presence of Structural SubtypingProceedings of the ACM on Programming Languages · 2026
- Peregrine: A Language-Agnostic Packet Processing Intermediate Representation with Formal GuaranteesarXiv · 2026
- Compositional Symbolic Execution \`a la Carte (Extended Version)arXiv · 2026