skip to main content
research-article

Principal Type Schemes for Gradual Programs

Published:14 January 2015Publication History
Skip Abstract Section

Abstract

Gradual typing is a discipline for integrating dynamic checking into a static type system. Since its introduction in functional languages, it has been adapted to a variety of type systems, including object-oriented, security, and substructural. This work studies its application to implicitly typed languages based on type inference. Siek and Vachharajani designed a gradual type inference system and algorithm that infers gradual types but still rejects ill-typed static programs. However, the type system requires local reasoning about type substitutions, an imperative inference algorithm, and a subtle correctness statement.

This paper introduces a new approach to gradual type inference, driven by the principle that gradual inference should only produce static types. We present a static implicitly typed language, its gradual counterpart, and a type inference procedure. The gradual system types the same programs as Siek and Vachharajani, but has a modular structure amenable to extension. The language admits let-polymorphism, and its dynamics are defined by translation to the Polymorphic Blame Calculus.

The principal types produced by our initial type system mask the distinction between static parametric polymorphism and polymorphism that can be attributed to gradual typing. To expose this difference, we distinguish static type parameters from gradual type parameters and reinterpret gradual type consistency accordingly. The resulting extension enables programs to be interpreted using either the polymorphic or monomorphic Blame Calculi.

Skip Supplemental Material Section

Supplemental Material

p303-sidebyside.mpg

References

  1. A. Ahmed, R. B. Findler, J. Matthews, and P. Wadler. Blame for all. In Proc. 1st Workshop on Script to Program Evolution, STOP '09, pages 1--13, New York, NY, USA, 2009. ACM. 10.1145/1570506.1570507. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. A. Ahmed, R. B. Findler, J. G. Siek, and P. Wadler. Blame for all. In Proc. Symposium on Principles of Programming Languages, POPL '11, pages 201--214, New York, NY, USA, 2011. ACM. 10.1145/1926385.1926409. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. G. Bierman, E. Meijer, and M. Torgersen. Adding dynamic types to C$^\#$. In T. D'Hondt, editor, Proc. 24th European Conference on Object-oriented Programming (ECOOP 2010), number 6183 in Lecture Notes in Computer Science, pages 76--100, Maribor, Slovenia, June 2010. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. R. Cartwright and M. Fagan. Soft typing. In Proc. Conference on Programming Language Design and Implementation, PLDI '91, pages 278--292, New York, NY, USA, 1991. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. D. Crystal. A dictionary of linguistics and phonetics. Blackwell, 2008.Google ScholarGoogle ScholarCross RefCross Ref
  6. S. K. Debray and D. S. Warren. Automatic mode inference for logic programs. Journal of Logic Programming, 5 (3): 207--229, Sept. 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. J.-Y. Girard. Interprétation fonctionelle et élimination des coupures de l'arithmétique d'ordre supérieur. PhD thesis, Université Paris VII, 1972.Google ScholarGoogle Scholar
  8. J. Gronski, K. Knowles, A. Tomb, S. N. Freund, and C. Flanagan. Sage: Hybrid checking for flexible specifications. In Proc. Scheme and Functional Programming Workshop, pages 93--104, 2006.Google ScholarGoogle Scholar
  9. J. Matthews and A. Ahmed. Parametric polymorphism through run-time sealing or, theorems for low, low prices! In Proc. European Conference on Programming Languages and Systems, ESOP'08/ETAPS'08, pages 16--31, Berlin, Heidelberg, 2008. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. J. Matthews and R. B. Findler. Operational semantics for multi-language programs. ACM Transactions on Programming Languages and Systems, 31 (3): 12:1--12:44, Apr. 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. R. Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17: 348--375, Aug. 1978.Google ScholarGoogle ScholarCross RefCross Ref
  12. A. Ohori. A simple semantics for ml polymorphism. In Proc. International Conference on Functional Programming Languages and Computer Architecture, FPCA '89, pages 281--292, New York, NY, USA, 1989. ACM. 10.1145/99370.99393. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. S. Peyton Jones, D. Vytiniotis, S. Weirich, and M. Shields. Practical type inference for arbitrary-rank types. Journal of Functional Programming, 17 (1): 1--82, Jan. 2007. 10.1017/S0956796806006034. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. B. C. Pierce. Types and programming languages. MIT Press, Cambridge, MA, USA, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. A. Rastogi, A. Chaudhuri, and B. Hosmer. The ins and outs of gradual type inference. In Proc. Symposium on Principles of Programming Languages, pages 481--494, New York, NY, USA, 2012. ACM. 10.1145/2103656.2103714. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. J. C. Reynolds. Towards a theory of type structure. In Programming Symposium, Proceedings Colloque Sur La Programmation, pages 408--423, London, UK, UK, 1974. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. J. A. Robinson. A machine-oriented logic based on the resolution principle. J. ACM, 12 (1): 23--41, Jan. 1965. ISSN 0004--5411. 10.1145/321250.321253. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. I. Sergey and D. Clarke. Gradual ownership types. In H. Seidl, editor, Proc. European Symposium on Programming Languages and Systems, volume 7211 of ESOP '12, pages 579--599, Tallinn, Estonia, 2012. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. J. Siek and W. Taha. Gradual typing for objects. In E. Ernst, editor, Proc. European Conference on Object-oriented Programming, number 4609 in ECOOP '07, pages 2--27, Berlin, Germany, July 2007. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. J. Siek, R. Garcia, and W. Taha. Exploring the design space of higher-order casts. In Proc. European Symposium on Programming Languages, ESOP '09, pages 17--31, Berlin, 2009. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. J. G. Siek and W. Taha. Gradual typing for functional languages. In Proc. Scheme and Functional Programming Workshop, pages 81--92, Sept. 2006.Google ScholarGoogle Scholar
  22. J. G. Siek and M. Vachharajani. Gradual typing with unification-based inference. In Proc. 2008 Symposium on Dynamic Languages, DLS '08, pages 7:1--7:12, New York, NY, USA, 2008. ACM. 10.1145/1408681.1408688. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. N. Swamy, C. Fournet, A. Rastogi, K. Bhargavan, J. Chen, P.-Y. Strub, and G. Bierman. Gradual typing embedded securely in JavaScript. In Proc. 41st ACM SIGPLAN-SIGACT symposium on Principles of programming languages (POPL 2014), pages 425--437, San Diego, CA, USA, Jan. 2014. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. S. Tobin-Hochstadt and M. Felleisen. Interlanguage migration: From scripts to programs. In Companion to the 21st ACM SIGPLAN Symposium on Object-oriented Programming Systems, Languages, and Applications, OOPSLA '06, pages 964--974, New York, NY, USA, 2006. ACM. ISBN 1--59593--491-X. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. S. Tobin-Hochstadt and M. Felleisen. The design and implementation of Typed Scheme. In Proc. 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2008), pages 395--406, San Francisco, CA, USA, Jan. 2008. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. P. Wadler and R. B. Findler. Well-typed programs can't be blamed. In Proc. European Symposium on Programming Languages, ESOP '09, pages 1--16, Berlin, 2009. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. M. Wand. A simple algorithm and proof for type inference. Fundamenta Infomaticae, 10: 115--122, 1987\natexlaba.Google ScholarGoogle ScholarCross RefCross Ref
  28. M. Wand. Complete type inference for simple objects. In Proc. 2nd IEEE Symposium on Logic in Computer Science, pages 37--44, 1987\natexlabb.Google ScholarGoogle Scholar
  29. R. Wolff, R. Garcia, É. Tanter, and J. Aldrich. Gradual typestate. In M. Mezini, editor, Proc. European Conference on Object-oriented Programming, volume 6813 of Lecture Notes in Computer Science, pages 459--483, Lancaster, UK, July 2011. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. A. K. Wright. Simple imperative polymorphism. Lisp Symb. Comput., 8 (4): 343--355, Dec. 1995. ISSN 0892--4635. 10.1007/BF01018828. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. A. K. Wright and M. Felleisen. A syntactic approach to type soundness. Journal of Information and Computation, 115 (1): 38--94, Nov. 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. T. Wrigstad, F. Zappa Nardelli, S. Lebresne, J. Östlund, and J. Vitek. Integrating typed and untyped code in a scripting language. In Proc. 37th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages (POPL 2010), pages 377--388, Madrid, Spain, Jan. 2010. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Principal Type Schemes for Gradual Programs

      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 50, Issue 1
        POPL '15
        January 2015
        682 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2775051
        • Editor:
        • Andy Gill
        Issue’s Table of Contents
        • cover image ACM Conferences
          POPL '15: Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages
          January 2015
          716 pages
          ISBN:9781450333009
          DOI:10.1145/2676726

        Copyright © 2015 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 14 January 2015

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!