Cleanup. Change intro example

This commit is contained in:
JanUlrich 2024-05-17 20:28:15 +02:00
parent 11dd427c3f
commit 6a679f8ab0
2 changed files with 21 additions and 22 deletions

View File

@ -146,24 +146,24 @@ We prove soundness and aim for a good compromise between completeness and time c
\begin{figure}
\begin{minipage}{0.43\textwidth}
\begin{lstlisting}[style=java,label=lst:intro-example-typeless,caption=Missing return type]
genBox() {
if( ... ) {
return new Box(1);
} else {
return new Box("Str");
}
genList() {
if( ... ) {
return new List(1);
} else {
return new List("Str");
}
}
\end{lstlisting}
\end{minipage}%
\hfill
\begin{minipage}{0.55\textwidth}
\begin{lstlisting}[style=tfgj,caption=Type inference solution,label=lst:intro-example-typed]
Box<?> genBox() {
if( ... ) {
return new Box<Integer>(1);
} else {
return new Box<String>("Str");
}
List<?> genList() {
if( ... ) {
return new List<Integer>(1);
} else {
return new List<String>("Str");
}
}
\end{lstlisting}
\end{minipage}

View File

@ -252,7 +252,7 @@ whereas \rulename{Clear} and \rulename{Exclude} remove wildcard placeholders or
allow the constraint to be processed by \rulename{Prepare}.
\subsection{Adding Wildcards to the mix}
\unify{} is able to create wildcard solutions even when the input set of constraints do not contain any wildcard variables.
%\unify{} is able to create wildcard solutions even when the input set of constraints do not contain any wildcard variables.
%Input constraints originating from a completely untyped input program do not contain any existential types.
%Those are added during \unify{}.
Wildcard types are added preemptively and if necessary can be removed later down the line.
@ -264,8 +264,6 @@ results in $\tv{a} \doteq \wctype{\wildcard{X}{\tv{u}}{\tv{l}}}{List}{\rwildcard
The upper and lower bounds of the freshly generated wildcard $\rwildcard{X}$ are type placeholders.
If a second constraint like $\tv{a} \lessdot \exptype{List}{\type{String}}$
exists the wildcard $\rwildcard{X}$ has to be removed by setting both lower and upper bound to $\type{String}$.
\textit{Example:}
\begin{displaymath}
\prftree[r]{\rulename{Reduce}}{
\prftree[r]{\rulename{Subst}}{
@ -283,15 +281,16 @@ exists the wildcard $\rwildcard{X}$ has to be removed by setting both lower and
%Wildcards are bound to a type.
% and can therefore only be created at T <. a constraints
% After a reduce step the information to which Type the wildcard was bound is lost!
\begin{lstlisting}
<X> List<X> concat(List<X> l, List<X> r){ ... }
% \begin{lstlisting}
% <X> List<X> concat(List<X> l, List<X> r){ ... }
someList(){
return new List("String") :? new List(42);
}
\end{lstlisting}
% someList(){
% return new List("String") :? new List(42);
% }
% \end{lstlisting}
Constraints for the untyped \texttt{someList} method:
Take the introduction example from listing \ref{lst:intro-example}.
Constraints for the untyped \texttt{genList} method:
\begin{constraintset}
$\begin{array}{l}
\exptype{List}{\ntv{x}} \lessdot {\ntv{r}}, \type{String} \lessdot {\ntv{x}},