diff --git a/unify.tex b/unify.tex index 8405932..b8d0f15 100644 --- a/unify.tex +++ b/unify.tex @@ -1177,3 +1177,40 @@ C \cup \set{ \tv{a} \lessdot \wctype{\Delta'}{C}{[\ol{U}/\ol{X}]\ol{S}}} % a unifier of the form $\tv{a} \to \tv{b}$. % Otherwise the found solution is incorrect. % This only happens if the input constraints contain type variables with no upper bound constraint like $\tv{a} \lessdot \type{N}$. + +The motivating use case example for existential types in \cite{aModelForJavaWithWildcards} is not +type correct in \TamedFJ{} unfortunately. %Unify can calculate it though! +At least if we use the A-normal form transformation defined in chapter \cite{sec:anfTransformation}. +\begin{lstlisting}[style=java] + boolean cmp(Pair p) + Pair make(List l) + +X.List l = ... +cmp(make(l)) +\end{lstlisting} + +\begin{lstlisting}[style=tamedfj] +let v = { let x = l in make(x) } in cmp(v) +\end{lstlisting} +$\wctype{\rwildcard{X}}{Pair}{\rwildcard{X}, \rwildcard{X}}$ is a correct type for \texttt{v}. +But the T-Let rule does only allow a type in the form of $\wctype{\rwildcard{X},\rwildcard{Y}}{Pair}{\rwildcard{X},\rwildcard{Y}}$. +%why is X,Y^X_X.Pair not a valid type? +X,Y.Pair <. Pair +Y =. X +l =. x +u =. X + + + +let v : X,Y.Pair = { let x = l in make(x) } in cmp(v) + +Fix: +let x : X.List = l in cmp(make(x)) +% Does Unify calculate this solution? +x , Pair + +% which types are not allowed? the Same rule is the problem: here T <. a -> a =. T(without free variables) + +% Example that does not work with our TI: +Pair> <. +a <. X.Pair>