Modern DSL compiler architecture in OCaml our experience with Catala
summary
Catala is an OCaml DSL for encoding legal rules; this session explains how the compiler uses a single centralized AST plus object types as row variables and small GADTs to get typed subsets per pass, yielding reusable generic printers and traversals. Practical techniques include open-recursion shallow map for concise per-pass transforms, polymorphic annotations for positions and typing state, and tradeoffs (centralized definitions, some type-error verbosity). Code and examples live on the project GitHub.
AI-written summary · about
chapters (15)
- 0:00DSLs and Catala intro
- 1:09What is Catala
- 2:35Traditional compiler passes
- 4:00Hierarchical terms reduce boilerplate
- 5:25Flatten ASTs with subtyping
- 7:13Drawbacks of structural typing
- 8:18GADTs for pass-specific ASTs
- 10:03Row and object types
- 11:08Generic printers with GADTs
- 11:32Open recursion for ASTs
- 12:57Multi-pass with GADTs
- 15:06Annotate AST nodes
- 16:10Limitations and trade-offs
- 17:15Strengths of unified AST
- 18:17Q&A
related talks
22mTurning Catala into a Proof Platform for the Law
40mDomain Specific Type Systems
19mInterpreting OCaml GADTs into Coq
26mAn Invitation to OCaml
15mTowards a Coq Specification for Generalized Algebraic Datatypes in OCaml
21mTail Modulo Cons, OCaml, and Relational Separation Logic
49mFrom DOT to Dotty
31mAdvanced techniques for building Kotlin DSL(s)
