MLstruct: Principal Type Inference in a Boolean Algebra of Structural Types

被引:14
|
作者
Parreaux, Lionel [1 ]
Chau, Chun Yin [1 ]
机构
[1] HKUST, Hong Kong, Peoples R China
来源
PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL | 2022年 / 6卷 / OOPSLA期
关键词
principal type inference; union and intersection types; structural typing; INTERSECTION; POLYMORPHISM; MODEL;
D O I
10.1145/3563304
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Intersection and union types are becoming more popular by the day, entering the mainstream in programming languages like TypeScript and Scala 3. Yet, no language so far has managed to combine these powerful types with principal polymorphic type inference. We present a solution to this problem in MLstruct, a language with subtyped records, equirecursive types, first-class unions and intersections, class-instance matching, and ML-style principal type inference. While MLstruct is mostly structurally typed, it contains a healthy sprinkle of nominality for classes, which gives it desirable semantics, enabling the expression of a powerful form of extensible variants that does not need row variables. Technically, we define the constructs of our language using conjunction, disjunction, and negation connectives, making sure they form a Boolean algebra, and we show that the addition of a few nonstandard subtyping rules gives us enough structure to derive a sound and complete type inference algorithm. With this work, we hope to foster the development of better type inference for present and future programming languages with expressive subtyping systems.
引用
收藏
页码:449 / 478
页数:30
相关论文
共 50 条