Omnidirectional type inference for ML: principality any way
Alistair O'Brien, Didier R\'emy, Gabriel Scherer

TL;DR
This paper introduces omnidirectional type inference, a dynamic approach that restores principality in ML-like systems with fragile features, enabling more expressive and flexible type inference.
Contribution
It proposes a novel omnidirectional inference framework with incremental instantiation, overcoming static limitations and handling features like overloading and first-class polymorphism.
Findings
Achieves more expressive principal types than OCaml's current typechecker.
Successfully applies to static overloading of labels and semi-explicit polymorphism.
Restores principality in ML extensions with fragile constructs.
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. Unfortunately, many extensions of ML (GADTs, higher-rank polymorphism, and static overloading) endanger princpality 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…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
