Affiliation:
1. University of Louisiana at Lafayette, USA
2. Oregon State University, USA
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.
Funder
National Science Foundation
Air Force Research Laboratory
Publisher
Association for Computing Machinery (ACM)
Subject
Safety, Risk, Reliability and Quality,Software
Cited by
15 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Type-Based Gradual Typing Performance Optimization;Proceedings of the ACM on Programming Languages;2024-01-05
2. Inference of Resource Management Specifications;Proceedings of the ACM on Programming Languages;2023-10-16
3. How Profilers Can Help Navigate Type Migration;Proceedings of the ACM on Programming Languages;2023-10-16
4. How to Evaluate Blame for Gradual Types, Part 2;Proceedings of the ACM on Programming Languages;2023-08-30
5. GTP Benchmarks for Gradual Typing Performance;Proceedings of the 2023 ACM Conference on Reproducibility and Replicability;2023-06-27