Abstract
FreezeML is a new approach to first-class polymorphic type inference that employs term annotations to control when and how polymorphic types are instantiated and generalised. It conservatively extends Hindley-Milner type inference and was first presented as an extension to Algorithm W. More modern type inference techniques such as HM(X) and OutsideIn(X) employ constraints to support features such as type classes, type families, rows, and other extensions. We take the first step towards modernising FreezeML by presenting a constraint-based type inference algorithm. We introduce a new constraint language, inspired by the Pottier/Rémy presentation of HM(X), in order to allow FreezeML type inference problems to be expressed as constraints. We present a deterministic stack machine for solving FreezeML constraints and prove its termination and correctness.
- Luís Damas and Robin Milner. 1982. Principal Type-Schemes for Functional Programs. In POPL. ACM Press, 207–212. https://doi.org/10.1145/582153.582176
Google Scholar
Digital Library
- Frank Emrich, Sam Lindley, Jan Stolarek, James Cheney, and Jonathan Coates. 2020. FreezeML: Complete and Easy Type Inference for First-class Polymorphism. In PLDI. ACM, 423–437. Extended version available at https://doi.org/10.48550/arXiv.2004.00396
Google Scholar
- Frank Emrich, Jan Stolarek, James Cheney, and Sam Lindley. 2022. Constraint-based type inference for FreezeML (extended version). https://doi.org/10.48550/arXiv.2207.09914 arXiv:2207.09914
Google Scholar
- Jacques Garrigue and Didier Rémy. 1999. Semi-Explicit First-Class Polymorphism for ML. Inf. Comput., 155, 1-2 (1999), 134–169. https://doi.org/10.1006/inco.1999.2830
Google Scholar
Digital Library
- Adam Gundry. 2015. A typechecker plugin for units of measure: domain-specific constraint solving in GHC Haskell. In Proceedings of the 8th ACM SIGPLAN Symposium on Haskell, Haskell 2015, Vancouver, BC, Canada, September 3-4, 2015, Ben Lippmeier (Ed.). ACM, 11–22. https://doi.org/10.1145/2804302.2804305
Google Scholar
Digital Library
- Adam Gundry, Conor McBride, and James McKinna. 2010. Type Inference in Context. In [email protected]. ACM, 43–54. https://doi.org/10.1006/inco.1999.2830
Google Scholar
Digital Library
- Mark P. Jones. 1994. A Theory of Qualified Types. Sci. Comput. Program., 22, 3 (1994), 231–256. https://doi.org/10.1016/0167-6423(94)00005-0
Google Scholar
Digital Library
- Andrew Kennedy. 2009. Types for Units-of-Measure: Theory and Practice. In CEFP (Lecture Notes in Computer Science, Vol. 6299). Springer, 268–305. https://doi.org/10.1007/978-3-642-17685-2_8
Google Scholar
Cross Ref
- George Kuan and David MacQueen. 2007. Efficient type inference using ranked type variables. In ML. ACM, 3–14. https://doi.org/10.1145/1292535.1292538
Google Scholar
Digital Library
- Didier Le Botlan and Didier Rémy. 2003. ML^ F: raising ML to the power of System F. In ICFP. ACM, 27–38. https://doi.org/10.1145/944705.944709
Google Scholar
Digital Library
- Daan Leijen. 2008. HMF: simple type inference for first-class polymorphism. In ICFP. ACM, 283–294. https://doi.org/10.1145/1411204.1411245
Google Scholar
Digital Library
- Daan Leijen. 2014. Koka: Programming with Row Polymorphic Effect Types. In MSFP (EPTCS, Vol. 153). 100–126. https://doi.org/10.4204/EPTCS.153.8
Google Scholar
Cross Ref
- Xavier Leroy and Michel Mauny. 1993. Dynamics in ML. J. Funct. Program., 3, 4 (1993), 431–463. https://doi.org/10.1017/S0956796800000848
Google Scholar
Cross Ref
- Sam Lindley and James Cheney. 2012. Row-based effect types for database integration. In TLDI. ACM, 91–102. https://doi.org/10.1145/2103786.2103798
Google Scholar
Digital Library
- J. Garrett Morris and James McKinna. 2019. Abstracting extensible data types: or, rows by any other name. Proc. ACM Program. Lang., 3, POPL (2019), 12:1–12:28. https://doi.org/10.1145/3290325
Google Scholar
Digital Library
- Martin Odersky, Martin Sulzmann, and Martin Wehr. 1999. Type Inference with Constrained Types. Theory Pract. Object Syst., 5, 1 (1999), 35–55.
Google Scholar
Digital Library
- Frank Pfenning. 1993. On the Undecidability of Partial Polymorphic Type Reconstruction. Fundam. Inform., 19, 1/2 (1993), 185–199.
Google Scholar
Digital Library
- François Pottier. 2014. Hindley-Milner Elaboration in Applicative Style: Functional Pearl. In ICFP. ACM, 203–212. https://doi.org/10.1145/2628136.2628145
Google Scholar
Digital Library
- François Pottier and Didier Rémy. 2005. The Essence of ML Type Inference. MIT Press, 389–489.
Google Scholar
- Didier Rémy. 1992. Extension of ML Type System with a Sorted Equational Theory on Types. Institut National de Recherche en Informatique et en Automatique.
Google Scholar
- Claudio V. Russo and Dimitrios Vytiniotis. 2009. QML: Explicit First-class Polymorphism for ML. In ML. ACM, 3–14.
Google Scholar
- Alejandro Serrano, Jurriaan Hage, Simon Peyton Jones, and Dimitrios Vytiniotis. 2020. A quick look at impredicativity. Proc. ACM Program. Lang., 4, ICFP (2020), 89:1–89:29. https://doi.org/10.1145/3408971
Google Scholar
Digital Library
- Alejandro Serrano, Jurriaan Hage, Dimitrios Vytiniotis, and Simon Peyton Jones. 2018. Guarded impredicative polymorphism. In PLDI. ACM, 783–796. https://doi.org/10.1145/3192366.3192389
Google Scholar
Digital Library
- Vincent Simonet and François Pottier. 2007. A constraint-based approach to guarded algebraic data types. ACM Trans. Program. Lang. Syst., 29, 1 (2007), 1. https://doi.org/10.1145/1180475.1180476
Google Scholar
Digital Library
- Dimitrios Vytiniotis, Simon L. Peyton Jones, Tom Schrijvers, and Martin Sulzmann. 2011. OutsideIn(X): Modular type inference with local assumptions. J. Funct. Program., 21, 4-5 (2011), 333–412. https://doi.org/10.1017/S0956796811000098
Google Scholar
Digital Library
- Dimitrios Vytiniotis, Stephanie Weirich, and Simon L. Peyton Jones. 2006. Boxy types: inference for higher-rank types and impredicativity. In ICFP. ACM, 251–262. https://doi.org/10.1145/1159803.1159838
Google Scholar
Digital Library
- Mitchell Wand. 1987. A simple algorithm and proof for type inference. Fundamenta Informaticae.
Google Scholar
- J. B. Wells. 1994. Typability and Type-Checking in the Second-Order lambda-Calculus are Equivalent and Undecidable. In LICS. IEEE Computer Society, 176–185. https://doi.org/10.1109/LICS.1994.316068
Google Scholar
Cross Ref
- Andrew K. Wright. 1995. Simple Imperative Polymorphism. LISP Symb. Comput., 8, 4 (1995), 343–355.
Google Scholar
Digital Library
Index Terms
Constraint-based type inference for FreezeML
Recommendations
FreezeML: complete and easy type inference for first-class polymorphism
PLDI 2020: Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and ImplementationML is remarkable in providing statically typed polymorphism without the programmer ever having to write any type annotations. The cost of this parsimony is that the programmer is limited to a form of polymorphism in which quantifiers can occur only at ...
MLF: raising ML to the power of system F
ICFP '03: Proceedings of the eighth ACM SIGPLAN international conference on Functional programmingWe propose a type system MLF that generalizes ML with first-class polymorphism as in System F. Expressions may contain second-order type annotations. Every typable expression admits a principal type, which however depends on type annotations. Principal ...
MLF: raising ML to the power of system F
We propose a type system MLF that generalizes ML with first-class polymorphism as in System F. Expressions may contain second-order type annotations. Every typable expression admits a principal type, which however depends on type annotations. Principal ...






Comments