skip to main content
research-article
Open Access
Artifacts Available
Artifacts Evaluated & Functional

Migrating gradual types

Published:27 December 2017Publication History
Skip Abstract Section

Abstract

Gradual typing allows programs to enjoy the benefits of both static typing and dynamic typing. While it is often desirable to migrate a program from more dynamically-typed to more statically-typed or vice versa, gradual typing itself does not provide a way to facilitate this migration. This places the burden on programmers who have to manually add or remove type annotations. Besides the general challenge of adding type annotations to dynamically typed code, there are subtle interactions between these annotations in gradually typed code that exacerbate the situation. For example, to migrate a program to be as static as possible, in general, all possible combinations of adding or removing type annotations from parameters must be tried out and compared.

In this paper, we address this problem by developing migrational typing, which efficiently types all possible ways of adding or removing type annotations from a gradually typed program. The typing result supports automatically migrating a program to be as static as possible, or introducing the least number of dynamic types necessary to remove a type error. The approach can be extended to support user-defined criteria about which annotations to modify. We have implemented migrational typing and evaluated it on large programs. The results show that migrational typing scales linearly with the size of the program and takes only 2–4 times longer than plain gradual typing.

Skip Supplemental Material Section

Supplemental Material

migratinggradualtypes.webm

References

  1. Amal Ahmed, Robert Bruce Findler, Jeremy G. Siek, and Philip Wadler. 2011. Blame for All. SIGPLAN Not. 46, 1 (Jan. 2011), 201–214. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Amal Ahmed, Dustin Jamner, Jeremy G. Siek, and Philip Wadler. 2017. Theorems for Free for Free: Parametricity, with and Without Types. Proc. ACM Program. Lang. 1, ICFP, Article 39 (Aug. 2017), 28 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Esteban Allende, Johan Fabry, Ronald Garcia, and Éric Tanter. 2014. Confined Gradual Typing. SIGPLAN Not. 49, 10 (Oct. 2014), 251–270. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Sven Apel, Don Batory, Christian Kästner, and Gunter Saake. 2016. Feature-Oriented Software Product Lines. Springer.Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Giuseppe Castagna and Victor Lanvin. 2017. Gradual Typing with Union and Intersection Types. Proc. ACM Program. Lang. 1, ICFP, Article 41 (Aug. 2017), 28 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Sheng Chen and Martin Erwig. 2014a. Counter-factual Typing for Debugging Type Errors. In Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’14). ACM, New York, NY, USA, 583–594. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Sheng Chen and Martin Erwig. 2014b. Guided Type Debugging. In Int. Symp. on Functional and Logic Programming (LNCS 8475). 35–51. Google ScholarGoogle ScholarCross RefCross Ref
  8. Sheng Chen and Martin Erwig. 2016. Principal Type Inference for GADTs. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’16). ACM, New York, NY, USA, 416–428. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Sheng Chen, Martin Erwig, and Eric Walkingshaw. 2012. An Error-tolerant Type System for Variational Lambda Calculus. In Proceedings of the 17th ACM SIGPLAN International Conference on Functional Programming (ICFP ’12). ACM, New York, NY, USA, 29–40. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Sheng Chen, Martin Erwig, and Eric Walkingshaw. 2014. Extending Type Inference to Variational Programs. ACM Trans. Program. Lang. Syst. 36, 1, Article 1 (March 2014), 54 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Sheng Chen, Martin Erwig, and Eric Walkingshaw. 2016. A Calculus for Variational Programming. In European Conf. on Object-Oriented Programming (ECOOP). 6:1–6:26.Google ScholarGoogle Scholar
  12. Matteo Cimini and Jeremy G. Siek. 2016. The Gradualizer: A Methodology and Algorithm for Generating Gradual Type Systems. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’16). ACM, New York, NY, USA, 443–455. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Matteo Cimini and Jeremy G. Siek. 2017. Automatically Generating the Dynamic Semantics of Gradually Typed Languages. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017). ACM, New York, NY, USA, 789–803. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Martin Erwig and Eric Walkingshaw. 2011. The Choice Calculus: A Representation for Software Variation. ACM Trans. Softw. Eng. Methodol. 21, 1, Article 6 (Dec. 2011), 27 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Martin Erwig and Eric Walkingshaw. 2013. Variation Programming with the Choice Calculus. In Generative and Transformational Techniques in Software Engineering (LNCS 7680). 55–99. Google ScholarGoogle ScholarCross RefCross Ref
  16. Ronald Garcia and Matteo Cimini. 2015. Principal Type Schemes for Gradual Programs. In Proceedings of the 42Nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’15). ACM, New York, NY, USA, 303–315. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Ronald Garcia, Alison M. Clark, and Éric Tanter. 2016. Abstracting Gradual Typing. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’16). ACM, New York, NY, USA, 429–442. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Atsushi Igarashi, Peter Thiemann, Vasco T. Vasconcelos, and Philip Wadler. 2017. Gradual Session Types. Proc. ACM Program. Lang. 1, ICFP, Article 38 (Aug. 2017), 28 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Khurram A. Jafery and Joshua Dunfield. 2017. Sums of Uncertainty: Refinements Go Gradual. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017). ACM, New York, NY, USA, 804–817. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Nico Lehmann and Éric Tanter. 2017. Gradual Refinement Types. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017). ACM, New York, NY, USA, 775–788. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Meng Meng, Jens Meinicke, Chu-Pan Wong, Eric Walkingshaw, and Christian Kästner. 2017. A Choice of Variational Stacks: Exploring Variational Data Structures. In Int. Work. on Variability Modelling of Software-Intensive Systems (VaMoS). ACM, 28–35. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Hung Viet Nguyen, Christian Kästner, and Tien N Nguyen. 2014. Exploring Variability-Aware Execution for Testing Plugin-Based Web Applications. In Int. Conf. on Software Engineering. ACM, 907–918. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Aseem Rastogi, Avik Chaudhuri, and Basil Hosmer. 2012. The Ins and Outs of Gradual Type Inference. SIGPLAN Not. 47, 1 (Jan. 2012), 481–494. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Ilya Sergey and Dave Clarke. 2012. Gradual Ownership Types. In Proceedings of the 21st European Conference on Programming Languages and Systems (ESOP’12). Springer-Verlag, Berlin, Heidelberg, 579–599. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Jeremy Siek and Walid Taha. 2007. Gradual Typing for Objects. In Proceedings of the 21st European Conference on ECOOP 2007: Object-Oriented Programming (ECOOP ’07). Springer-Verlag, Berlin, Heidelberg, 2–27. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Jeremy G. Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In IN SCHEME AND FUNCTIONAL PROGRAMMING WORKSHOP. 81–92.Google ScholarGoogle Scholar
  27. Jeremy G. Siek and Manish Vachharajani. 2008. Gradual Typing with Unification-based Inference. In Proceedings of the 2008 Symposium on Dynamic Languages (DLS ’08). ACM, New York, NY, USA, Article 7, 12 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. 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, Vol. 32. Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik.Google ScholarGoogle Scholar
  29. Karl Smeltzer and Martin Erwig. 2017. Variational Lists: Comparisons and Design Guidelines. In Int. Work. on Feature-Oriented Software Development (FOSD). ACM, 31–40. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Asumu Takikawa, Daniel Feltey, Ben Greenman, Max S. New, Jan Vitek, and Matthias Felleisen. 2016. Is Sound Gradual Typing Dead?. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’16). ACM, New York, NY, USA, 456–468. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Wesley Tansey and Eli Tilevich. 2008. Annotation Refactoring: Inferring Upgrade Transformations for Legacy Applications. In Proceedings of the 23rd ACM SIGPLAN Conference on Object-oriented Programming Systems Languages and Applications (OOPSLA ’08). ACM, New York, NY, USA, 295–312. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Thomas Thüm, Sven Apel, Christian Kästner, Ina Schaefer, and Gunter Saake. 2014. A Classification and Survey of Analysis Strategies for Software Product Lines. 47, 1 (6 2014), 6:1–6:45.Google ScholarGoogle Scholar
  33. Sam Tobin-Hochstadt, Matthias Felleisen, Robert Findler, Matthew Flatt, Ben Greenman, Andrew M. Kent, Vincent St-Amour, T. Stephen Strickland, and Asumu Takikawa. 2017. Migratory Typing: Ten Years Later. In 2nd Summit on Advances in Programming Languages (SNAPL 2017) (Leibniz International Proceedings in Informatics (LIPIcs)), Benjamin S. Lerner, Rastislav Bodík, and Shriram Krishnamurthi (Eds.), Vol. 71. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany, 17:1–17:17. Google ScholarGoogle ScholarCross RefCross Ref
  34. Peter van Keeken. 2006. Analyzing Helium Programs Obtained Through Logging–The process of mining novice Haskell programs. Master’s thesis. Department of Information and Computing Sciences, Utrecht University.Google ScholarGoogle Scholar
  35. Dimitrios Vytiniotis, Simon Peyton Jones, and José Pedro Magalhães. 2012. Equality Proofs and Deferred Type Errors: A Compiler Pearl. In Proceedings of the 17th ACM SIGPLAN International Conference on Functional Programming (ICFP ’12). ACM, New York, NY, USA, 341–352. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Dimitrios Vytiniotis, Simon Peyton jones, Tom Schrijvers, and Martin Sulzmann. 2011. Outsidein(x) Modular Type Inference with Local Assumptions. J. Funct. Program. 21, 4-5 (Sept. 2011), 333–412. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. 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: Held As Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2009 (ESOP ’09). Springer-Verlag, Berlin, Heidelberg, 1–16. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Eric Walkingshaw, Christian Kästner, Martin Erwig, Sven Apel, and Eric Bodden. 2014. Variational Data Structures: Exploring Tradeoffs in Computing with Variability. In Proceedings of the 2014 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software (Onward! 2014). ACM, New York, NY, USA, 213–226. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Eric Walkingshaw and Klaus Ostermann. 2014. Projectional Editing of Variational Software. In ACM SIGPLAN Int. Conf. on Generative Programming: Concepts and Experiences (GPCE). ACM, 29–38. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Migrating gradual types

    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

    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!