Simple Type Inference for Structural Polymorphism.
Jacques Garrigue · 2001
We propose a new way to mix constrained types and type inference, where the interaction between the two is minimal. By using local constraints embedded in types, rather than the other way round, we obtain a system which keeps the usual structure of an Hindley-Milner type system. In practice, this means that it is easy to introduce local constraints in existing type inference algorithms. Eventhough our system is notably weaker than general constraintbased type systems, making it unable to handle subtyping for instance, it is powerful enough to accomodate many features, from simple polymorphic records à la Ohori to Objective Caml’s polymorphic variants, and accurate typing of pattern matching (i.e. polymorphic message dispatch), all these through tiny variations in the constraint part of the system. 1.