Type engineering in OCaml, Illustrated on the OCaml Compiler
summary
Ongoing five‑year refactoring of the OCaml compiler’s type checker and pattern matcher aims to trade ad hoc complexity for named records, constrained GADTs, and targeted uses of polymorphic and extensible variants; the codebase spans ~30 years and 350+ contributors so changes are conservative. Practical choices: prefer records over wide tuples, use objects used only in native backend for open recursion, use first-class modules switch Windows/Unix implementation, and remove or rewrite format has a 12-parameter constructor (huge binary cost) via deprecation and a ppx replacement.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 0:42Why refactor OCaml compiler
- 2:25Types for safe refactoring
- 6:26Product types in OCaml
- 9:18Objects and first-class modules
- 12:08Variance in OCaml types
- 15:24Extensible variants and ADTs
- 17:12Abstract data types
- 20:51GADTs for pattern matching
- 23:23Complexity of format strings
- 24:48Type engineering conclusion
- 25:52Q&A session
