QML: Explicit First-Class Polymorphism for ML

  • Claudio Russo ,
  • Dimitrios Vytiniotis

ML '09 Proceedings of the 2009 ACM SIGPLAN workshop on ML |

Published by ACM New York, NY, USA

Publication

Recent years have seen a revival of interest in extending ML’s predicative type inference system with impredicative quantification in the style of System F, for which type inference is undecidable. This paper suggests a modest extension of ML with System F types: the heart of the idea is to extend the language of types with unary universal and existential quantifiers. The introduction and elimination of a quantified type is never inferred but indicated explicitly by the programmer by supplying the quantified type itself. Quantified types co-exist with ordinary ML schemes, which are in turn implicitly introduced and eliminated at let-bindings and use sites, respectively. The resulting language, QML, does not impose any restriction on instantiating quantified variables with quantified types; neither let- nor λ-bound variables ever require a type annotation, even if the variable’s inferred scheme or type involves quantified types. This proposal, albeit more verbose in terms of annotations than others, is simple to specify, implement, understand, and formalize.