Type-safe Nanopasses: How to write a safe and modern compiler front-end
summary
Ada front end for Infer compiles Liong parse trees to CIL by composing many tiny, type-safe nanopasses implemented in OCaml, using recursion schemes for traversal and polymorphic variants to represent overlapping node sets. A small PPX that emits map/union diffs plus a PPX generator reduces boilerplate; the pipeline ends up as 36 passes, most <200 LOC, one large pass for defaults, and the whole reengineer takes about a year and yields maintainable, statically checked transformations.
AI-written summary · about
chapters (7)
- 0:00Context and objectives
- 3:50Small separated passes
- 8:40Type-safe pass architecture
- 12:15Avoiding boilerplate code
- 20:33Implementation techniques
- 26:23Results and conclusions
- 30:00Q&A and discussion
related talks
23mTyped, Concise, Nanopass (pick 3) (Extended Abstract)
41mWriting a Nanopass Compiler
25mNano-parsing: A Data-parallel Architecture for Perverse Parsing Environments
34mEfficient Nanopass Compilers using Cats and Matryoshka
29mNanopass Attribute Grammars
26mAn alternative to CPP
08mCompiling pattern matching to in-place modifications
15mEfficient Compilation of Algebraic Effect Handlers
