Type inference, principal typings, and let-polymorphism for first-class mixin modules

Henning Makholm, J. B. Wells

Research output: Contribution to journalArticle

Abstract

A mixin module is a programming abstraction that simultaneously generalizes ?-abstractions, records, and mutually recursive definitions. Although various mixin module type systems have been developed, no one has investigated principal typings or developed type inference for first-class mixin modules, nor has anyone added Milner's let-polymorphism to such a system. This paper proves that typability is NP-complete for the naive approach followed by previous mixin module type systems. Because a ?-calculus extended with record concatenation is a simple restriction of our mixin module calculus, we also prove the folk belief that typability is NP-complete for the naive early type systems for record concatenation. To allow feasible type inference, we present Martini, a new system of simple types for mixin modules with principal typings. Martini is conceptually simple, with no subtyping and a clean and balanced separation between unification-based type inference with type and row variables and constraint solving for safety of linking and field extraction. We have implemented a type inference algorithm and we prove its complexity to be O(n2), or O(n) given a fixed bound on the number of field labels.1 To prove the complexity, we need to present an algorithm for row unification that may have been implemented by others, but which we could not find written down anywhere. Because Martini has principal typings, we successfully extend it with Milner's let-polymorphism. Copyright © 2005 ACM.

Original languageEnglish
Pages (from-to)156-167
Number of pages12
JournalACM SIGPLAN Notices
Volume40
Issue number9
DOIs
Publication statusPublished - 2005

Fingerprint

Polymorphism

Keywords

  • Mixin modules
  • Polymorphism
  • Record concatenation
  • Row unification
  • Type systems

Cite this

@article{064fb3869708493db7645e93bceadbf9,
title = "Type inference, principal typings, and let-polymorphism for first-class mixin modules",
abstract = "A mixin module is a programming abstraction that simultaneously generalizes ?-abstractions, records, and mutually recursive definitions. Although various mixin module type systems have been developed, no one has investigated principal typings or developed type inference for first-class mixin modules, nor has anyone added Milner's let-polymorphism to such a system. This paper proves that typability is NP-complete for the naive approach followed by previous mixin module type systems. Because a ?-calculus extended with record concatenation is a simple restriction of our mixin module calculus, we also prove the folk belief that typability is NP-complete for the naive early type systems for record concatenation. To allow feasible type inference, we present Martini, a new system of simple types for mixin modules with principal typings. Martini is conceptually simple, with no subtyping and a clean and balanced separation between unification-based type inference with type and row variables and constraint solving for safety of linking and field extraction. We have implemented a type inference algorithm and we prove its complexity to be O(n2), or O(n) given a fixed bound on the number of field labels.1 To prove the complexity, we need to present an algorithm for row unification that may have been implemented by others, but which we could not find written down anywhere. Because Martini has principal typings, we successfully extend it with Milner's let-polymorphism. Copyright {\circledC} 2005 ACM.",
keywords = "Mixin modules, Polymorphism, Record concatenation, Row unification, Type systems",
author = "Henning Makholm and Wells, {J. B.}",
year = "2005",
doi = "10.1145/1090189.1086386",
language = "English",
volume = "40",
pages = "156--167",
journal = "ACM SIGPLAN Notices",
issn = "0362-1340",
publisher = "Association for Computing Machinery (ACM)",
number = "9",

}

Type inference, principal typings, and let-polymorphism for first-class mixin modules. / Makholm, Henning; Wells, J. B.

In: ACM SIGPLAN Notices, Vol. 40, No. 9, 2005, p. 156-167.

Research output: Contribution to journalArticle

TY - JOUR

T1 - Type inference, principal typings, and let-polymorphism for first-class mixin modules

AU - Makholm, Henning

AU - Wells, J. B.

PY - 2005

Y1 - 2005

N2 - A mixin module is a programming abstraction that simultaneously generalizes ?-abstractions, records, and mutually recursive definitions. Although various mixin module type systems have been developed, no one has investigated principal typings or developed type inference for first-class mixin modules, nor has anyone added Milner's let-polymorphism to such a system. This paper proves that typability is NP-complete for the naive approach followed by previous mixin module type systems. Because a ?-calculus extended with record concatenation is a simple restriction of our mixin module calculus, we also prove the folk belief that typability is NP-complete for the naive early type systems for record concatenation. To allow feasible type inference, we present Martini, a new system of simple types for mixin modules with principal typings. Martini is conceptually simple, with no subtyping and a clean and balanced separation between unification-based type inference with type and row variables and constraint solving for safety of linking and field extraction. We have implemented a type inference algorithm and we prove its complexity to be O(n2), or O(n) given a fixed bound on the number of field labels.1 To prove the complexity, we need to present an algorithm for row unification that may have been implemented by others, but which we could not find written down anywhere. Because Martini has principal typings, we successfully extend it with Milner's let-polymorphism. Copyright © 2005 ACM.

AB - A mixin module is a programming abstraction that simultaneously generalizes ?-abstractions, records, and mutually recursive definitions. Although various mixin module type systems have been developed, no one has investigated principal typings or developed type inference for first-class mixin modules, nor has anyone added Milner's let-polymorphism to such a system. This paper proves that typability is NP-complete for the naive approach followed by previous mixin module type systems. Because a ?-calculus extended with record concatenation is a simple restriction of our mixin module calculus, we also prove the folk belief that typability is NP-complete for the naive early type systems for record concatenation. To allow feasible type inference, we present Martini, a new system of simple types for mixin modules with principal typings. Martini is conceptually simple, with no subtyping and a clean and balanced separation between unification-based type inference with type and row variables and constraint solving for safety of linking and field extraction. We have implemented a type inference algorithm and we prove its complexity to be O(n2), or O(n) given a fixed bound on the number of field labels.1 To prove the complexity, we need to present an algorithm for row unification that may have been implemented by others, but which we could not find written down anywhere. Because Martini has principal typings, we successfully extend it with Milner's let-polymorphism. Copyright © 2005 ACM.

KW - Mixin modules

KW - Polymorphism

KW - Record concatenation

KW - Row unification

KW - Type systems

U2 - 10.1145/1090189.1086386

DO - 10.1145/1090189.1086386

M3 - Article

VL - 40

SP - 156

EP - 167

JO - ACM SIGPLAN Notices

JF - ACM SIGPLAN Notices

SN - 0362-1340

IS - 9

ER -