arXiv · 2210.04729
The Foil: Capture-Avoiding Substitution With No Sharp Edges
Abstract
Correctly manipulating program terms in a compiler is surprisingly difficult because of the need to avoid name capture. The rapier from "Secrets of the Glasgow Haskell Compiler inliner" is a cutting-edge technique for fast, stateless capture-avoiding substitution for expressions represented with explicit names. It is, however, a sharp tool: its invariants are tricky and need to be maintained throughout the whole compiler that uses it. We describe the foil, an elaboration of the rapier that uses Haskell's type system to enforce the rapier's invariants statically, preventing a class of hard-to-find bugs, but without adding any run-time overheads.
Explore related subjects
Keep this discovery
Dougal Maclaurin, Alexey Radul, Adam Paszke. 2022-10-10. The Foil: Capture-Avoiding Substitution With No Sharp Edges. https://arxiv.org/abs/2210.04729
Cite the original work for its findings. Save a collection to share your selection of sources.