Solver-based Gradual Type Migration

09/10/2021
by   Luna Phipps-Costin, et al.
0

Gradually typed languages allow programmers to mix statically and dynamically typed code, enabling them to incrementally reap the benefits of static typing as they add type annotations to their code. However, this type migration process is typically a manual effort with limited tool support. This paper examines the problem of automated type migration: given a dynamic program, infer additional or improved type annotations. Existing type migration algorithms prioritize different goals, such as maximizing type precision, maintaining compatibility with unmigrated code, and preserving the semantics of the original program. We argue that the type migration problem involves fundamental compromises: optimizing for a single goal often comes at the expense of others. Ideally, a type migration tool would flexibly accommodate a range of user priorities. We present TypeWhich, a new approach to automated type migration for the gradually-typed lambda calculus with some extensions. Unlike prior work, which relies on custom solvers, TypeWhich produces constraints for an off-the-shelf MaxSMT solver. This allows us to easily express objectives, such as minimizing the number of necessary syntactic coercions, and constraining the type of the migration to be compatible with unmigrated code. We present the first comprehensive evaluation of GTLC type migration algorithms, and compare TypeWhich to four other tools from the literature. Our evaluation uses prior benchmarks, and a new set of “challenge problems.” Moreover, we design a new evaluation methodology that highlights the subtleties of gradual type migration. In addition, we apply TypeWhich to a suite of benchmarks for Grift, a programming language based on the GTLC. TypeWhich is able to reconstruct all human-written annotations on all but one program.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
02/23/2023

Do Machine Learning Models Produce TypeScript Types That Type Check?

Type migration is the process of adding types to untyped code to gain as...
research
07/05/2019

MigrationMiner: An Automated Detection Tool of Third-Party Java Library Migration at the Method Level

In this paper we introduce, MigrationMiner, an automated tool that detec...
research
02/07/2020

SLACC: Simion-based Language Agnostic Code Clones

Successful cross-language clone detection could enable researchers and d...
research
12/04/2020

Supporting Round-Trip Data Migration for Web APIs: A Henshin Solution

We present a solution to the Round-Trip Migration case of the Transforma...
research
03/21/2022

Migrating CUDA to oneAPI: A Smith-Waterman Case Study

To face the programming challenges related to heterogeneous computing, I...
research
01/26/2023

User-Customizable Transpilation of Scripting Languages

A transpiler converts code from one programming language to another. Man...
research
03/25/2022

C to Checked C by 3C

Owing to the continued use of C (and C++), spatial safety violations (e....

Please sign up or login with your details

Forgot password? Click here to reset