different types. For example, ad-hoc polymorphism is necessary to
allow an overloaded operator +, which is simultaneously addition
of integers (of type int → int → int) and concatenation of lists (of
type ∀α.list[α] → list[α] → list[α]).
Kaes [13] presented a system extending ML, combining para-
metric polymorphic, subtyping and overloading, and a similar sys-
tem lifting some of its restrictions was later given by Smith [20].
However, both systems infer types with an explicit collection
of constraints, rather than just a type term. With their language
ML
≤
, Bourdoncle and Merz [3] present a language combining ML
with object-oriented programming, supporting CLOS-style multi-
method dispatch, which also infers constrained types.
6.4 Automata and Simplification
Representing types as automata is a standard technique, which
has been used to tackle subtyping, entailment and simplification.
Kozen, Palsberg and Schwartzbach [14] gave an algorithm based on
automata for efficiently deciding subtyping between ground types
of Amadio and Cardelli’s system. Henglein and Rehof [10] reduced
the problem of NFA universality to entailment in the Amadio-
Cardelli system, thus proving it PSPACE-hard. In fact, our repre-
sentation theorem began life as an attempt to find a sort of converse
to Henglein and Rehof’s result. Niehren and Priesnitz [17] stud-
ied also entailment using a form of finite automata (their cap-set
automata, explained in detail in Priesnitz’s thesis [19]). Eifrig et
al. [8], Trifonov and Smith [22], Pottier [18] all use some form of
automata for simplifying types.
7. Conclusion
We have presented MLsub, a minimal language subsuming the
Hindley-Milner calculus with let-polymorphism integrated seam-
lessly with subtyping. An implementation is available online.
We improve on previous work in this area by offering an algo-
rithm to infer compact types (syntactic terms, rather than a term
and a possibly-large set of constraints), and proving that these are
principal.
We provide a general means of simplifying types and typing
schemes: instead of specifying a particular simplification algo-
rithm, our representation theorem shows that anything from the lit-
erature of finite automata and regular languages can be used.
Languages incorporating ML-style type inference often have
interesting type system features not present in the core calculus,
such as advanced module systems, GADTs, typeclasses, etc. We are
interested in seeing which of these constructs can be implemented
(or even continue to make sense) in the context of MLsub.
Acknowledgements Thanks to Leo White for discussions about
MLsub, particularly on the relationship between the ML-style and
reformulated rules, to Derek Dreyer for helpful comments about
the presentation of this paper, and to the anonymous referees. This
work was funded by Trinity College, Cambridge, and OCaml Labs.
References
[1] R. M. Amadio and L. Cardelli. Subtyping recursive types. ACM
Transactions on Programming Languages and Systems (TOPLAS), 15
(4), 1993.
[2] H. Beki
ˇ
c. Definable operations in general algebras, and the theory of
automata and flowcharts. In C. Jones, editor, Programming Languages
and Their Definition, volume 177 of Lecture Notes in Computer Sci-
ence, pages 30–55. Springer Berlin Heidelberg, 1984.
[3] F. Bourdoncle and S. Merz. Type checking higher-order polymorphic
multi-methods. In POPL ’97: 24th ACM Symposium on Principles of
Programming Languages, pages 302–315, Paris, Jan. 1997. ACM.
[4] G. Castagna and Z. Xu. Set-theoretic foundation of parametric poly-
morphism and subtyping. In Proceedings of the 16th ACM SIG-
PLAN International Conference on Functional Programming, ICFP
’11, pages 94–106. ACM, 2011.
[5] B. A. Davey and H. A. Priestley. Introduction to lattices and order.
Cambridge University Press, 2002.
[6] S. Dolan. Algebraic Subtyping. PhD thesis, University of Cambridge,
2016. To appear.
[7] J. Eifrig, S. Smith, and V. Trifonov. Type inference for recursively
constrained types and its application to OOP. Electronic Notes in The-
oretical Computer Science, 1:132–153, 1995. MFPS XI, Mathemati-
cal Foundations of Programming Semantics, Eleventh Annual Confer-
ence.
[8] J. Eifrig, S. Smith, and V. Trifonov. Sound polymorphic type infer-
ence for objects. In Proceedings of the Tenth Annual Conference on
Object-oriented Programming Systems, Languages, and Applications,
OOPSLA ’95, pages 169–184. ACM, 1995.
[9] F. Henglein and J. Rehof. The complexity of subtype entailment for
simple types. In Logic in Computer Science, 1997. LICS’97. Proceed-
ings., 12th Annual IEEE Symposium on, pages 352–361. IEEE, 1997.
[10] F. Henglein and J. Rehof. Constraint automata and the complexity
of recursive subtype entailment. In 25th International Colloquium on
Automata, Languages and Programming, ICALP ’98, pages 616–627.
Springer Berlin Heidelberg, 1998.
[11] M. Hoang and J. C. Mitchell. Lower bounds on type inference with
subtypes. In Proceedings of the 22nd ACM SIGPLAN-SIGACT Sym-
posium on Principles of Programming Languages, POPL ’95, pages
176–185. ACM, 1995.
[12] L. Ilie, G. Navarro, and S. Yu. On NFA reductions. In J. Karhum
¨
aki,
H. Maurer, G. P
˘
aun, and G. Rozenberg, editors, Theory Is Forever,
volume 3113 of Lecture Notes in Computer Science, pages 112–124.
Springer Berlin Heidelberg, 2004.
[13] S. Kaes. Type inference in the presence of overloading, subtyping and
recursive types. In Proceedings of the 1992 ACM Conference on LISP
and Functional Programming, LFP ’92, pages 193–204. ACM, 1992.
[14] D. Kozen, J. Palsberg, and M. I. Schwartzbach. Efficient recursive
subtyping. In Proceedings of the 20th ACM SIGPLAN-SIGACT Sym-
posium on Principles of Programming Languages, POPL ’93, pages
419–428. ACM, 1993.
[15] A. Martelli and U. Montanari. An efficient unification algorithm. ACM
Transactions on Programming Languages and Systems (TOPLAS), 4
(2):258–282, 1982.
[16] J. Niehren and T. Priesnitz. Entailment of non-structural subtype con-
straints. In P. Thiagarajan and R. Yap, editors, Advances in Computing
Science — ASIAN’99, volume 1742 of Lecture Notes in Computer Sci-
ence, pages 251–265. Springer Berlin Heidelberg, 1999.
[17] J. Niehren and T. Priesnitz. Non-structural subtype entailment in au-
tomata theory. In N. Kobayashi and B. C. Pierce, editors, Theoretical
Aspects of Computer Software, volume 2215 of Lecture Notes in Com-
puter Science, pages 360–384. Springer Berlin Heidelberg, 2001.
[18] F. Pottier. Type inference in the presence of subtyping: from theory to
practice. PhD thesis, Universit
´
e Paris 7, 1998.
[19] T. Priesnitz. Subtype Satisfiability and Entailment. PhD thesis, Saar-
land University, 2004.
[20] G. S. Smith. Principal type schemes for functional programs with
overloading and subtyping. Science of Computer Programming, 23
(2):197–226, 1994.
[21] Z. Su, A. Aiken, J. Niehren, T. Priesnitz, and R. Treinen. The first-
order theory of subtyping constraints. In Proceedings of the 29th
ACM SIGPLAN-SIGACT Symposium on Principles of Programming
Languages, POPL ’02, pages 203–216. ACM, 2002.
[22] V. Trifonov and S. Smith. Subtyping constrained types. In R. Cousot
and D. A. Schmidt, editors, Static Analysis, volume 1145 of Lecture
Notes in Computer Science, pages 349–365. Springer Berlin Heidel-
berg, 1996.
[23] A. K. Wright and M. Felleisen. A syntactic approach to type sound-
ness. Information and computation, 115(1):38–94, 1994.
13 2016/11/7