skip to main content
research-article
Open Access

Consistent Subtyping for All

Published:21 November 2019Publication History
Skip Abstract Section

Abstract

Consistent subtyping is employed in some gradual type systems to validate type conversions. The original definition by Siek and Taha serves as a guideline for designing gradual type systems with subtyping. Polymorphic types à la System F also induce a subtyping relation that relates polymorphic types to their instantiations. However, Siek and Taha’s definition is not adequate for polymorphic subtyping. The first goal of this article is to propose a generalization of consistent subtyping that is adequate for polymorphic subtyping and subsumes the original definition by Siek and Taha. The new definition of consistent subtyping provides novel insights with respect to previous polymorphic gradual type systems, which did not employ consistent subtyping. The second goal of this article is to present a gradually typed calculus for implicit (higher-rank) polymorphism that uses our new notion of consistent subtyping. We develop both declarative and (bidirectional) algorithmic versions for the type system. The algorithmic version employs techniques developed by Dunfield and Krishnaswami for higher-rank polymorphism to deal with instantiation. We prove that the new calculus satisfies all static aspects of the refined criteria for gradual typing. We also study an extension of the type system with static and gradual type parameters, in an attempt to support a variant of the dynamic criterion for gradual typing. Assuming a coherence conjecture for the extended calculus, we show that the dynamic gradual guarantee of our source language can be reduced to that of λ B, which, at the time of writing, is still an open question. Most of the metatheory of this article, except some manual proofs for the algorithmic type system and extensions, has been mechanically formalized using the Coq proof assistant.

References

  1. Martin Abadi, Luca Cardelli, Benjamin Pierce, and Didier Rémy. 1995. Dynamic typing in polymorphic languages. J. Funct. Program. 5, 1 (1995), 111--130.Google ScholarGoogle ScholarCross RefCross Ref
  2. Amal Ahmed, Robert Bruce Findler, Jeremy G. Siek, and Philip Wadler. 2011. Blame for all. In Proceedings of the 38th Symposium on Principles of Programming Languages.Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Amal Ahmed, Dustin Jamner, Jeremy G. Siek, and Philip Wadler. 2017. Theorems for free for free: Parametricity, with and without types. In Proceedings of the 22nd International Conference on Functional Programming.Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Felipe Bañados Schwerter, Ronald Garcia, and Éric Tanter. 2014. A theory of gradual effect systems. In Proceedings of the 19th International Conference on Functional Programming.Google ScholarGoogle Scholar
  5. Gavin Bierman, Martín Abadi, and Mads Torgersen. 2014. Understanding typescript. In Proceedings of the 28th European Conference on Object-Oriented Programming.Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Gavin Bierman, Erik Meijer, and Mads Torgersen. 2010. Adding dynamic types to C#. In Proceedings of the European Conference on Object-Oriented Programming.Google ScholarGoogle Scholar
  7. Ambrose Bonnaire-Sergeant, Rowan Davies, and Sam Tobin-Hochstadt. 2016. Practical optional types for clojure. In Programming Languages and Systems.Google ScholarGoogle Scholar
  8. Luca Cardelli. 1993. An Implementation of FSub. Technical Report. Research Report 97, Digital Equipment Corporation Systems Research Center.Google ScholarGoogle Scholar
  9. Giuseppe Castagna and Victor Lanvin. 2017. Gradual typing with union and intersection types. Proc. ACM Program. Lang. 1, Article 41 (Aug. 2017).Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Alonzo Church. 1941. The Calculi of Lambda-conversion. Number 6. Princeton University Press.Google ScholarGoogle Scholar
  11. Matteo Cimini and Jeremy G. Siek. 2016. The gradualizer: A methodology and algorithm for generating gradual type systems. In Proceedings of the 43rd Symposium on Principles of Programming Languages.Google ScholarGoogle Scholar
  12. Matteo Cimini and Jeremy G. Siek. 2017. Automatically generating the dynamic semantics of gradually typed languages. In Proceedings of the 44th Symposium on Principles of Programming Languages.Google ScholarGoogle Scholar
  13. Haskell Brooks Curry, Robert Feys, William Craig, J. Roger Hindley, and Jonathan P. Seldin. 1958. Combinatory Logic. Vol. 1. North-Holland Amsterdam.Google ScholarGoogle Scholar
  14. Luis Damas and Robin Milner. 1982. Principal type-schemes for functional programs. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL’82). 6.Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Rowan Davies and Frank Pfenning. 2000. Intersection types and computational effects. In Proceedings of the 5th ACM SIGPLAN International Conference on Functional Programming (ICFP’00). ACM, New York, NY, 198--208. DOI:https://doi.org/10.1145/351240.351259Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Dominique Devriese, Marco Patrignani, and Frank Piessens. 2017. Parametricity versus the universal type. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL’17), Vol. 2, 38.Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Joshua Dunfield and Neelakantan R. Krishnaswami. 2013. Complete and easy bidirectional typechecking for higher-rank polymorphism. In Proceedings of the International Conference on Functional Programming. https://arxiv.org/abs/1306.6032.Google ScholarGoogle Scholar
  18. Ronald Garcia and Matteo Cimini. 2015. Principal type schemes for gradual programs. In Proceedings of the 42nd Symposium on Principles of Programming Languages.Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Ronald Garcia, Alison M. Clark, and Éric Tanter. 2016. Abstracting gradual typing. In Proceedings of the 43rd Symposium on Principles of Programming Languages.Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Jessica Gronski, Kenneth Knowles, Aaron Tomb, Stephen N. Freund, and Cormac Flanagan. 2006. Sage: Hybrid checking for flexible specifications. In Proceedings of the Scheme and Functional Programming Workshop.Google ScholarGoogle Scholar
  21. J. Roger Hindley. 1969. The principal type-scheme of an object in combinatory logic. Trans. Amer. Math. Soc. 146 (1969), 29--60.Google ScholarGoogle Scholar
  22. Yuu Igarashi, Taro Sekiyama, and Atsushi Igarashi. 2017. On polymorphic gradual typing. In Proceedings of the 22nd International Conference on Functional Programming.Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Khurram A. Jafery and Joshua Dunfield. 2017. Sums of uncertainty: Refinements go gradual. In Proceedings of the 44th Symposium on Principles of Programming Languages. 14.Google ScholarGoogle Scholar
  24. Mark P. Jones. 2000. Type classes with functional dependencies. In Proceedings of the European Symposium on Programming. Springer, 230--244.Google ScholarGoogle ScholarCross RefCross Ref
  25. Simon Peyton Jones, Mark Jones, and Erik Meijer. 1997. Type classes: Exploring the design space. In Proceedings of the Haskell Workshop, Vol. 1997.Google ScholarGoogle Scholar
  26. Oleg Kiselyov, Ralf Lämmel, and Keean Schupke. 2004. Strongly typed heterogeneous collections. In Proceedings of the ACM SIGPLAN Workshop on Haskell. ACM, 96--107.Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Didier Le Botlan and Didier Rémy. 2003. MLF: Raising ML to the power of system F. In Proceedings of the International Conference on Functional Programming (ICFP’03). 12.Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Didier Le Botlan and Didier Rémy. 2009. Recasting MLF. Info. Comput. 207, 6 (2009), 726--785.Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Jukka Lehtosalo et al. 2006. Mypy. Retrieved from http://www.mypy-lang.org/.Google ScholarGoogle Scholar
  30. Daan Leijen. 2009. Flexible types: Robust type inference for first-class polymorphism. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL’09). 12.Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Jacob Matthews and Amal Ahmed. 2008. Parametric polymorphism through run-time sealing or, theorems for low, low prices! In Proceedings of the European Symposium on Programming. Springer, 16--31.Google ScholarGoogle Scholar
  32. Conor McBride. 2002. Faking it simulating dependent types in Haskell. J. Funct. Program. 12, 4--5 (2002), 375--392.Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. John C. Mitchell. 1990. Polymorphic type inference and containment. In Logical Foundations of Functional Programming. Addison-Wesley, Boston, MA.Google ScholarGoogle Scholar
  34. James H. Morris, Jr. 1973. Types are not sets. In Proceedings of the 1st Annual ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL’73). ACM, New York, NY, 120--124. DOI:https://doi.org/10.1145/512927.512938Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. James Hiram Morris Jr. 1969. Lambda-calculus Models of Programming Languages. Ph.D. Dissertation. Massachusetts Institute of Technology.Google ScholarGoogle Scholar
  36. Georg Neis, Derek Dreyer, and Andreas Rossberg. 2009. Non-parametric parametricity. In Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming (ICFP’09). ACM, New York, NY, 135--148. DOI:https://doi.org/10.1145/1596550.1596572Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Martin Odersky and Konstantin Läufer. 1996. Putting type annotations to work. In Proceedings of the 23rd Symposium on Principles of Programming Languages.Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Michel Parigot. 1992. Recursive programming with proofs. Theor. Comput. Sci. 94, 2 (1992), 335--356.Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Mark Shields. 2007. Practical type inference for arbitrary-rank types. J. Funct. Program. 17, 1 (2007), 1--82.Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Benjamin C. Pierce. 2002. Types and Programming Languages. MIT Press.Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Didier Rémy and Boris Yakobowski. 2008. From ML to MLF: Graphic type constraints with efficient type inference. In Proceedings of the International Conference on Functional Programming (ICFP’08). 12.Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. John C. Reynolds. 1983. Types, abstraction and parametric polymorphism. In Proceedings of the IFIP 9th World Computer Congress.Google ScholarGoogle Scholar
  43. John C. Reynolds. 1991. The coherence of languages with intersection types. In Proceedings of the International Conference on Theoretical Aspects of Computer Software.Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Jeremy Siek, Ronald Garcia, and Walid Taha. 2009. Exploring the design space of higher-order casts. In Proceedings of the European Symposium on Programming. 17--31.Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Jeremy G. Siek and Walid Taha. 2006. Gradual typing for functional languages. In Proceedings of the Scheme and Functional Programming Workshop.Google ScholarGoogle Scholar
  46. Jeremy G. Siek and Walid Taha. 2007. Gradual typing for objects. In Proceedings of the European Conference on Object-Oriented Programming.Google ScholarGoogle Scholar
  47. Jeremy G. Siek and Manish Vachharajani. 2008. Gradual typing with unification-based inference. In Proceedings of the Symposium on Dynamic Languages.Google ScholarGoogle Scholar
  48. Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, and John Tang Boyland. 2015. Refined criteria for gradual typing. In LIPIcs-Leibniz International Proceedings in Informatics.Google ScholarGoogle Scholar
  49. Jeremy G. Siek and Philip Wadler. 2016. The Key to Blame: Gradual Typing Meets Cryptography (draft).Google ScholarGoogle Scholar
  50. Julien Verlaguet. 2013. Facebook: Analyzing PHP statically. In Proceedings of Commercial Users of Functional Programming.Google ScholarGoogle Scholar
  51. Michael M. Vitousek, Andrew M. Kent, Jeremy G. Siek, and Jim Baker. 2014. Design and evaluation of gradual typing for Python. In Proceedings of the 10th Symposium on Dynamic Languages.Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. Dimitrios Vytiniotis, Stephanie Weirich, and Simon Peyton Jones. 2008. FPH: First-class Polymorphism for Haskell. In Proceedings of the International Conference on Functional Programming (ICFP’08). 12.Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. Philip Wadler and Robert Bruce Findler. 2009. Well-typed programs can’t be blamed. In Proceedings of the 18th European Symposium on Programming Languages and Systems.Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. J. B. Wells. 1999. Typability and type checking in System F are equivalent and undecidable. Ann. Pure Appl. Logic 98, 1 (1999), 111--156. DOI:https://doi.org/10.1016/S0168-0072(98)00047-5Google ScholarGoogle ScholarCross RefCross Ref
  55. Ningning Xie, Xuan Bi, and Bruno C. d. S. Oliveira. 2018. Consistent subtyping for all. In Proceedings of the European Symposium on Programming. 3--30.Google ScholarGoogle Scholar

Index Terms

  1. Consistent Subtyping for All

        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 Transactions on Programming Languages and Systems
          ACM Transactions on Programming Languages and Systems  Volume 42, Issue 1
          Special Issue on ESOP 2018
          March 2020
          215 pages
          ISSN:0164-0925
          EISSN:1558-4593
          DOI:10.1145/3373084
          Issue’s Table of Contents

          Copyright © 2019 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: 21 November 2019
          • Accepted: 1 January 2019
          • Revised: 1 December 2018
          • Received: 1 May 2018
          Published in toplas Volume 42, Issue 1

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • research-article
          • Research
          • Refereed

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader

        HTML Format

        View this article in HTML Format .

        View HTML Format