|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: Merging Gradual Typing |
| 4 | +authors: Wenjia Ye |
| 5 | +date: 2024-4-23 10:10:00 +0800 |
| 6 | +venue: CB313 |
| 7 | +--- |
| 8 | + |
| 9 | +Programming language mechanisms with a type-directed semantics are nowadays common and widely |
| 10 | +used. Such mechanisms include gradual typing, type classes, implicits and intersection types with a merge |
| 11 | +operator. While sharing common challenges in their design and having complementary strengths, type-directed |
| 12 | +mechanisms have been mostly independently studied. |
| 13 | +This paper studies a new calculus, called λM⋆, which combines two type-directed mechanisms: gradual |
| 14 | +typing and a merge operator based on intersection types. Gradual typing enables a smooth transition between |
| 15 | +dynamically and statically typed code, and is available in languages such as TypeScript or Flow. The merge |
| 16 | +operator generalizes record concatenation to allow merges of values of any two types. Recent work has |
| 17 | +shown that the merge operator enables modelling expressive OOP features like first-class traits/classes and |
| 18 | +dynamic inheritance with static type-checking. These features are not found in mainstream statically typed |
| 19 | +OOP languages, but they can be found in dynamically or gradually typed languages such as JavaScript or |
| 20 | +TypeScript. In λM⋆, by exploiting the complementary strengths of gradual typing and the merge operator, |
| 21 | +we obtain a foundation for modelling gradually typed languages with both first-class classes and dynamic |
| 22 | +inheritance. We study a static variant of λM⋆ (called λM); prove the type-soundness of λM⋆; show that λM⋆ |
| 23 | +can encode gradual rows and all well-typed terms in the GTFL≲ calculus; and show that λM⋆ satisfies gradual |
| 24 | +criteria. The dynamic gradual guarantee (DGG) is challenging due to the possibility of ambiguity errors. We |
| 25 | +establish a variant of the DGG using a semantic notion of precision based on a step-indexed logical relation. |
0 commit comments