ACM Transactions on Programming Languages and Systems· 2026Q2
Omnidirectional type inference for ML: principality any way
- 1citations
- Q2SCImago
- 2026year
Short summary
A new omnidirectional type inference algorithm restores principality (unique most general type) to ML-like languages extended with fragile features like static overloading and first-class polymorphism, by allowing type information to flow dynamically rather than in a fixed order.
AI-generated from the title and abstract; the full text is not read.
Key points
- Proposes omnidirectional type inference, enabling dynamic information flow for type inference.
- Restores principality to ML-like languages with fragile constructs (e.g., GADTs, higher-rank polymorphism, static overloading).
- Introduces incremental instantiation to handle let-generalization with partially solved type schemes.
- Demonstrates improved expressiveness over current typecheckers for OCaml's static overloading and first-class polymorphism.
AI-generated from the title and abstract; the full text is not read.
Abstract
The Damas-Hindley-Milner (ML) type system owes its success to principality , the property that every well-typed expression has a unique most general type. This makes inference predictable and efficient. Yet, principality is fragile : many extensions of ML—GADTs, higher-rank polymorphism, and static overloading—break it by introducing fragile constructs that resist principal inference. Existing approaches recover principality through directional inference algorithms, which propagate known type information in a fixed (or static ) order ( e.g. as in bidirectional typing) to disambiguate such constructs. However, the rigidity of a static inference order often causes otherwise well-typed programs to be rejected. We propose omnidirectional type inference, where type information flows in a dynamic order. Typing constraints may be solved in any order, suspending when progress requires known type information and resuming once it becomes available, using suspended match constraints . This approach is straightforward for simply typed systems, but extending it to ML is challenging due to let-generalization . Existing ML inference algorithms type let-bindings in a fixed order—type the let-bound expression first, generalize its type, and then type the let-body. To overcome this, we introduce incremental instantiation , allowing partially solved type schemes containing suspended constraints to be instantiated, with a mechanism to incrementally update instances as the scheme is refined. Omnidirectionality provides a general framework for restoring principality in the presence of fragile features. We demonstrate its versatility on two fundamentally different features of OCaml: static overloading of record labels and datatype constructors and semi-explicit first-class polymorphism. In both cases, we obtain a principal type inference algorithm that is more expressive than OCaml’s current typechecker.
The authors' abstract, as published at the source. ACM Transactions on Programming Languages and Systems, 2026 · DOI ↗
Continue with a free account
Ask the paper: 3 free questions a day about this paper; save it, get its citation, new summaries every day for your field. Takeaways are Premium.
Continue free on the webSign in with Google or Apple; no card needed. You come back to this paper.
On your phone:
Field: Artificial Intelligence
Artificial IntelligenceComputer Science