skip to main content
research-article

Polymorphism, subtyping, and type inference in MLsub

Published:01 January 2017Publication History
Skip Abstract Section

Abstract

We present a type system combining subtyping and ML-style parametric polymorphism. Unlike previous work, our system supports type inference and has compact principal types. We demonstrate this system in the minimal language MLsub, which types a strict superset of core ML programs.

This is made possible by keeping a strict separation between the types used to describe inputs and those used to describe outputs, and extending the classical unification algorithm to handle subtyping constraints between these input and output types. Principal types are kept compact by type simplification, which exploits deep connections between subtyping and the algebra of regular languages. An implementation is available online.

References

  1. R. M. Amadio and L. Cardelli. Subtyping recursive types. ACM Transactions on Programming Languages and Systems (TOPLAS), 15 (4), 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Science, pages 30–55. Springer Berlin Heidelberg, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. G. Castagna and Z. Xu. Set-theoretic foundation of parametric polymorphism and subtyping. In Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming, ICFP ’11, pages 94–106. ACM, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. B. A. Davey and H. A. Priestley. Introduction to lattices and order. Cambridge University Press, 2002.Google ScholarGoogle ScholarCross RefCross Ref
  6. S. Dolan. Algebraic Subtyping. PhD thesis, University of Cambridge, 2016. To appear.Google ScholarGoogle Scholar
  7. J. Eifrig, S. Smith, and V. Trifonov. Type inference for recursively constrained types and its application to OOP. Electronic Notes in Theoretical Computer Science, 1:132–153, 1995. MFPS XI, Mathematical Foundations of Programming Semantics, 11th Annual Conference.Google ScholarGoogle ScholarCross RefCross Ref
  8. J. Eifrig, S. Smith, and V. Trifonov. Sound polymorphic type inference for objects. In Proceedings of the Tenth Annual Conference on Object-oriented Programming Systems, Languages, and Applications, OOPSLA ’95, pages 169–184. ACM, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. F. Henglein and J. Rehof. The complexity of subtype entailment for simple types. In Logic in Computer Science, 1997. LICS’97. Proceedings., 12th Annual IEEE Symposium on, pages 352–361. IEEE, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. Hoang and J. C. Mitchell. Lower bounds on type inference with subtypes. In Proceedings of the 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’95, pages 176–185. ACM, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. L. Ilie, G. Navarro, and S. Yu. On NFA reductions. In J. Karhumäki, H. Maurer, G. Păun, and G. Rozenberg, editors, Theory Is Forever, volume 3113 of Lecture Notes in Computer Science, pages 112–124. Springer Berlin Heidelberg, 2004.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. D. Kozen, J. Palsberg, and M. I. Schwartzbach. Efficient recursive subtyping. In Proceedings of the 20th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’93, pages 419–428. ACM, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. A. Martelli and U. Montanari. An efficient unification algorithm. ACM Transactions on Programming Languages and Systems (TOPLAS), 4 (2):258–282, 1982. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. J. Niehren and T. Priesnitz. Entailment of non-structural subtype constraints. In P. Thiagarajan and R. Yap, editors, Advances in Computing Science — ASIAN’99, volume 1742 of Lecture Notes in Computer Science, pages 251–265. Springer Berlin Heidelberg, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. J. Niehren and T. Priesnitz. Non-structural subtype entailment in automata theory. In N. Kobayashi and B. C. Pierce, editors, Theoretical Aspects of Computer Software, volume 2215 of Lecture Notes in Computer Science, pages 360–384. Springer Berlin Heidelberg, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. F. Pottier. Type inference in the presence of subtyping: from theory to practice. PhD thesis, Université Paris 7, 1998.Google ScholarGoogle Scholar
  19. T. Priesnitz. Subtype Satisfiability and Entailment. PhD thesis, Saarland University, 2004.Google ScholarGoogle Scholar
  20. G. S. Smith. Principal type schemes for functional programs with overloading and subtyping. Science of Computer Programming, 23 (2):197–226, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Z. Su, A. Aiken, J. Niehren, T. Priesnitz, and R. Treinen. The firstorder 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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Heidelberg, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. A. K. Wright and M. Felleisen. A syntactic approach to type soundness. Information and computation, 115(1):38–94, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Polymorphism, subtyping, and type inference in MLsub

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 52, Issue 1
          POPL '17
          January 2017
          901 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/3093333
          Issue’s Table of Contents
          • cover image ACM Conferences
            POPL '17: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages
            January 2017
            901 pages
            ISBN:9781450346603
            DOI:10.1145/3009837

          Copyright © 2017 ACM

          Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 1 January 2017

          Check for updates

          Qualifiers

          • research-article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader