Dynamic Type Inference for Gradual Hindley--Milner Typing

10/30/2018
by   Yusuke Miyazaki, et al.
0

Garcia and Cimini study a type inference problem for the ITGL, an implicitly and gradually typed language with let-polymorphism, and develop a sound and complete inference algorithm for it. Soundness and completeness mean that, if the algorithm succeeds, the input term can be translated to a well-typed term of an explicitly typed blame calculus by cast insertion and vice versa. However, in general, there are many possible translations depending on how type variables that were left undecided by static type inference are instantiated with concrete static types. Worse, the translated terms may behave differently---some evaluate to values but others raise blame. In this paper, we propose and formalize a new blame calculus λ^DTI_B that avoids such divergence as an intermediate language for the ITGL. A main idea is to allow a term to contain type variables (that have not been instantiated during static type inference) and defer instantiation of these type variables to run time. We introduce dynamic type inference (DTI) into the semantics of λ^DTI_B so that type variables are instantiated along reduction. The DTI-based semantics not only avoids the divergence described above but also is sound and complete with respect to the semantics of fully instantiated terms in the following sense: if the evaluation of a term succeeds (i.e., terminates with a value) in the DTI-based semantics, then there is a fully instantiated version of the term that also succeeds in the explicitly typed blame calculus and vice versa. Finally, we prove the gradual guarantee, which is an important correctness criterion of a gradually typed language, for the ITGL.

READ FULL TEXT
research
09/12/2019

Towards Gradually Typed Capabilities in the Pi-Calculus

Gradual typing is an approach to integrating static and dynamic typing w...
research
04/01/2020

FreezeML: Complete and Easy Type Inference for First-Class Polymorphism

ML is remarkable in providing statically typed polymorphism without the ...
research
10/18/2019

Gradual Typing for Extensibility by Rows

This work studies gradual typing for row types and row polymorphism. Key...
research
07/09/2023

Type-Preserving Compilation of Class-Based Languages

The Dependent Object Type (DOT) calculus was designed to put Scala on a ...
research
03/03/2022

Implicit Polarized F: local type inference for impredicativity

System F, the polymorphic lambda calculus, features the principle of imp...
research
05/17/2021

A Complete Axiomatisation for Divergence Preserving Branching Congruence of Finite-State Behaviours

We present an equational inference system for finite-state expressions, ...
research
06/10/2023

The Design Principles of the Elixir Type System

Elixir is a dynamically-typed functional language running on the Erlang ...

Please sign up or login with your details

Forgot password? Click here to reset