skip to main content
article

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

Published:12 September 2005Publication History
Skip Abstract Section

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. 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.

References

  1. D. Ancona, S. Fagorzi, E. Moggi, E. Zucca. Mixin modules and computational effects. In Proc. 30th Int'l Coll. Automata, Languages, and Programming, vol. 2719 of LNCS. Springer-Verlag, 2003.]]Google ScholarGoogle Scholar
  2. D. Ancona, S. Fagorzi, E. Zucca. A calculus with lazy module operators. In IFIP TC1 3rd Int'l Conf. Theoret. Comput. Sci. (TCS '04). Kluwer Academic Publishers, 2004.]]Google ScholarGoogle Scholar
  3. D. Ancona, E. Zucca. A primitive calculus for module systems. In Proc. Int'l Conf. Principles & Practice Declarative Programming, vol. 1702 of LNCS. Springer-Verlag, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. D. Ancona, E. Zucca. A calculus of module systems. J. Funct. Programming, 12(2), 2002. Extended version of {3}.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. D. Duggan, C. Sourelis. Mixin modules. In Proc. 1996 Int'l Conf. Functional Programming. ACM Press, 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Programming Languages & Systems, 9th European Symp. Programming, vol. 1782 of LNCS. Springer-Verlag, 2000.]]Google ScholarGoogle Scholar
  7. M. Flatt, M. Felleisen. Units: Cool modules for HOT languages. In Proc. ACM SIGPLAN '98 Conf. Prog. Lang. Design & Impl., 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. R. Harper, B. C. Pierce. A record calculus based on symmetric concatenation. Technical Report CMU-CS-90-157R, Carnegie Mellon Univ., 1991.]]Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. R. Harper, B. C. Pierce. A record calculus based on symmetric concatenation. In Conf. Rec. 18th Ann. ACM Symp. Princ. of Prog. Langs., 1991.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. T. Hirschowitz. Mixin Modules, Modules, and Extended Recursion in a Call-by-Value Setting. PhD thesis, Université Paris 7, 2003.]]Google ScholarGoogle Scholar
  11. T. Hirschowitz. Rigid mixin modules. In Seventh International Symposium on Functional and Logic Programming (FLOPS 2004), 2004.]]Google ScholarGoogle ScholarCross RefCross Ref
  12. T. Hirschowitz, X. Leroy. Mixin modules in a call-by-value setting. In Programming Languages & Systems, 11th European Symp. Programming, vol. 2305 of LNCS. Springer-Verlag, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. T. Hirschowitz, X. Leroy, J. B. Wells. Call-by-value mixin modules: Reduction semantics, side effects, types. In Programming Languages & Systems, 13th European Symp. Programming, vol. 2986 of LNCS. Springer-Verlag, 2004. More details can be found in {10}.]]Google ScholarGoogle Scholar
  14. H. Makholm, J. B. Wells. Type inference, principal typings, and letpolymorphism for first-class mixin modules. Technical report, Heriot-Watt Univ., School of Math. & Comput. Sci., 2005.]]Google ScholarGoogle Scholar
  15. A. Ohori, P. Buneman. Type inference in a database programming language. In Proc. 1988 ACM Conf. LISP Funct. Program., Snowbird, Utah, U.S.A., 1988.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. J. Palsberg, T. Zhao. Type inference for record concatenation and subtyping. Inform. & Comput., 189, 2004.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. F. Pottier. A 3-part type inference engine. In ESOP '00 {6}.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. F. Pottier. A versatile constraint-based type inference system. Nordic Journal of Computing, 7(4), 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. F. Pottier. A constraint-based presentation and generalization of rows. In Proc. 18th Ann. IEEE Symp. Logic in Comput. Sci., 2003.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. F. Pottier, D. Rémy. The essence of ML type inference. In B. C. Pierce, ed., Advanced Topics in Types and Programming Languages, chapter 10. MIT Press, Cambridge, Massachusetts, 2005.]]Google ScholarGoogle Scholar
  21. D. Rémy. Typing record concatenation for free. In Conf. Rec. 19th Ann. ACM Symp. Princ. of Prog. Langs., 1992. A later version is {22}.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. D. Rémy. Typing record concatenation for free. In C. A. Gunter, J. C. Mitchell, eds., Theoretical Aspects Of Object-Oriented Programming: Types, Semantics and Language Design. MIT Press, 1993.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. D. Rémy. A case study of typechecking with constrained types: Typing record concatenation. Presented at the workshop on Advances in Types for Computer Science at the Newton Institute, Cambridge, UK, 1995.]]Google ScholarGoogle Scholar
  24. R. E. Tarjan. Efficiency of a good but not linear set union algorithm. J. ACM, 22(2), 1975.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. S. Vansummeren. On the complexity of deciding typability in the relational algebra. Acta Informatica, 200X. To appear.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. M. Wand. Complete type inference for simple objects. In Proc. 2nd Ann. Symp. Logic in Comput. Sci., 1987. A corrigendum appeared at LICS 1988.]]Google ScholarGoogle Scholar
  27. M. Wand. Type inference for record concatenation and multiple inheritance. In Proc. 4th Ann. Symp. Logic in Comput. Sci., Pacific Grove, CA, U.S.A., 1989. IEEE Comput. Soc. Press.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. M. Wand. Type inference for record concatenation and multiple inheritance. Inform. & Comput., 93, 1991.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. J. B. Wells. The essence of principal typings. In Proc. 29th Int'l Coll. Automata, Languages, and Programming, vol. 2380 of LNCS. Springer-Verlag, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. J. B.Wells, R. Vestergaard. Confluent equational reasoning for linking with first-class primitive modules (long version). A short version is {31}. Full paper, 3 appendices of proofs, 1999.]]Google ScholarGoogle Scholar
  31. J. B. Wells, R. Vestergaard. Equational reasoning for linking with first-class primitive modules. In ESOP '00 {6}. A long version is {30}.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. J. Zwanenburg. A type system for record concatenation and subtyping. In K. Bruce, G. Longo, eds., Third Workshop on Foundations of Object Oriented Languages (FOOL 3), Rutgers Univ., NJ, USA, 1996.]]Google ScholarGoogle Scholar

Index Terms

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

      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 40, Issue 9
        Proceedings of the tenth ACM SIGPLAN international conference on Functional programming
        September 2005
        330 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/1090189
        Issue’s Table of Contents
        • cover image ACM Conferences
          ICFP '05: Proceedings of the tenth ACM SIGPLAN international conference on Functional programming
          September 2005
          342 pages
          ISBN:1595930647
          DOI:10.1145/1086365

        Copyright © 2005 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 ACM 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: 12 September 2005

        Check for updates

        Qualifiers

        • article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader