@@ -11,10 +11,9 @@ program is free of type errors, and moreover, soundness of the equational theory
...
@@ -11,10 +11,9 @@ program is free of type errors, and moreover, soundness of the equational theory
that program optimizations are valid.
that program optimizations are valid.
Meanwhile, dynamic typing allows the programmer to rapidly prototype
Meanwhile, dynamic typing allows the programmer to rapidly prototype
their application code without needing to commit to fixed type signatures for their
their application code without needing to commit to fixed type signatures for their
functions. Unfortunately, most languages choose between static or dynamic typing.
functions. Most languages choose between static or dynamic typing and as a result, programmers that initially write their code in a dynamically typed language
As a result, programmers that initially write their code in a dynamically typed language
in order to benefit from faster prototyping and development time need to rewrite the
in order to benefit from faster prototyping and development time will need to rewrite the
some or all of their codebase in a static language if they would like to receive the benefits of static
entire codebase in a static language if they would like to receive the benefits of static
typing once their codebase has matured.
typing once their codebase has matured.
\emph{Gradually-typed languages}\cite{siek-taha06, tobin-hochstadt06} seek to resolve this tension
\emph{Gradually-typed languages}\cite{siek-taha06, tobin-hochstadt06} seek to resolve this tension
...
@@ -36,7 +35,6 @@ dynamic to static, and allow for those different parts to interact with one anot
...
@@ -36,7 +35,6 @@ dynamic to static, and allow for those different parts to interact with one anot
Moreover, gradually-typed languages should support the smooth migration from
Moreover, gradually-typed languages should support the smooth migration from
dynamic typing to static typing, in that the programmer can initially leave off the
dynamic typing to static typing, in that the programmer can initially leave off the
typing annotations and provide them later without altering the meaning of the program.
typing annotations and provide them later without altering the meaning of the program.
% Sound gradual typing
% Sound gradual typing
Furthermore, the parts of the program that are written in a dynamic style should soundly
Furthermore, the parts of the program that are written in a dynamic style should soundly
interoperate with the parts that are written in a static style.
interoperate with the parts that are written in a static style.
...
@@ -53,16 +51,32 @@ violated the typing contract imposed by statically typed code.
...
@@ -53,16 +51,32 @@ violated the typing contract imposed by statically typed code.
% this interaction should respect the guarantees made by the static types.
% this interaction should respect the guarantees made by the static types.
% Graduality property
% Graduality property
Formally speaking, gradually typed languages should satisfy the
One of the fundamental theorems for gradually typed languages is
\emph{dynamic gradual guarantee}, originally defined by Siek, Vitousek, Cimini,
\emph{dynamic gradual guarantee}, originally defined by Siek, Vitousek, Cimini,
and Boyland \cite{siek_et_al:LIPIcs:2015:5031}.
and Boyland \cite{siek_et_al:LIPIcs:2015:5031}, also called \emph{graduality}\cite{new-ahmed2018},
This property is also referred to as \emph{graduality}\cite{new-ahmed2018},
by analogy with parametricity.
by analogy with parametricity.
Intuitively, graduality says that going from a dynamic to static style should not
Informally, graduality says that going from a dynamic to static style should only allow for the introduction of static or dynamic type errors, and not otherwise change the meaning of the program.
introduce changes in the meaning of the program.
%
More specifically, making the types more precise by adding typing annotations
This is a way to capture programmer intuition that increasing type
will either result in the same behavior as the original, less precise program,
precision corresponds to a generalized form assertions at runtime
or will result in a type error.
only, and so they can trust that prior observed behavior of their
dynamically typed code will remain unchanged as long as it satisfies
the new stricter typing discipline.
Additionally, gradually typed languages should offer some of the
benefits of static typing. While classical type soundness, that
well-typed programs are free from runtime errors, is not compatible
with runtime type errors, we can instead focus on \emph{type-based
reasoning}. For instance, while dynamically typed $\lambda$ calculi
only satisfy $\beta$ equality for their type formers, statically typed