Fixes
This commit is contained in:
@ -0,0 +1,19 @@
|
||||
@article{MILNER,
|
||||
title = {A theory of type polymorphism in programming},
|
||||
journal = {Journal of Computer and System Sciences},
|
||||
volume = {17},
|
||||
number = {3},
|
||||
pages = {348-375},
|
||||
year = {1978},
|
||||
issn = {0022-0000},
|
||||
doi = {https://doi.org/10.1016/0022-0000(78)90014-4},
|
||||
url = {www.sciencedirect.com/science/article/pii/0022000078900144},
|
||||
author = {Robin Milner},
|
||||
}
|
||||
|
||||
@inproceedings{REMY,
|
||||
title={Extension of ML type system with a sorted equation theory on types},
|
||||
author={Didier R{\'e}my},
|
||||
year={1992},
|
||||
url={https://api.semanticscholar.org/CorpusID:117549268}
|
||||
}
|
||||
Binary file not shown.
@ -153,7 +153,7 @@
|
||||
\newcommand{\defeq}{\vcentcolon=}
|
||||
|
||||
\lstdefinelanguage{miniimp}{
|
||||
keywords={if, then, else, skip, while, do, for, rand},
|
||||
keywords={if, then, else, skip, while, do, for, rand, let},
|
||||
keywordstyle=\color{blue}\bfseries,
|
||||
identifierstyle=\color{black},
|
||||
sensitive=false,
|
||||
@ -202,6 +202,8 @@
|
||||
|
||||
\input{report}
|
||||
|
||||
\printbibliography{}
|
||||
|
||||
\end{document}
|
||||
|
||||
%% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %%
|
||||
|
||||
@ -426,6 +426,38 @@ output := y;
|
||||
|
||||
To see a list of all options run \texttt{dune exec <interpreter> {-}{-} -h}. A binary version of the executables can also be found in the build directory: \href{./_build/default/bin/}{./\_build/default/bin/}.
|
||||
\end{section}
|
||||
|
||||
|
||||
\begin{section}{Addendum: Algorithm W}
|
||||
Added since the last submission a simplified version of the Algorithm W from {\bf A Theory of Type Polymorphism in Programming}\cite{MILNER}. The implementation uses levels instead of prefexes and does not contain the fixed point as described in {\bf Extension of ML type system with a sorted equation theory on types}\cite{REMY} and \href{https://okmij.org/ftp/ML/generalization.html}{okmij.org/ftp/ML/generalization.html}. Thus \texttt{let rec} is not implemented. But the remaining grammar is fully polimorphically typable.
|
||||
An interpreter that outputs the type of the input program is provided as \href{../bin/miniFunPolyInterpreter.ml}{miniFunPolyInterpreter.ml}. The interpreter admits program that are not functions from integers to integers like with the other interpreter, so the evaluation of the program with input is disabled by default. Otherwise the only possible types of programs would be \(\texttt{Int} \to \texttt{Int}\), \(\forall \texttt{a}, \texttt{a} \to \texttt{Int}\) and \(\forall \texttt{a}, \texttt{a} \to \texttt{a}\) since they can be all unified to \(\texttt{Int} \to \texttt{Int}\).
|
||||
In addition the character \texttt{?} is mapped to the new type \texttt{Unknown}. The new type is not used by the program and any type specification is ignored. The \texttt{?} symbol is just a useful shorthand.
|
||||
|
||||
|
||||
Some examples:
|
||||
\begin{lstlisting}
|
||||
let f =
|
||||
\z: ? =>
|
||||
\y: ? =>
|
||||
\x: ? =>
|
||||
if x < 0 then y x else z x
|
||||
in f
|
||||
\end{lstlisting}
|
||||
|
||||
is correctly evaluated as having the type \( \forall \texttt{a}, (\texttt{Int} \to \texttt{a}) \to (\texttt{Int} \to \texttt{a}) \to \texttt{Int} \to \texttt{a} \).
|
||||
|
||||
\begin{lstlisting}
|
||||
let f =
|
||||
\z: ? =>
|
||||
\y: ? =>
|
||||
\x: ? =>
|
||||
if x < 0 then y x else z x
|
||||
in
|
||||
f (\x: ? => \y: ? => \z: ? => if fst y then snd y else snd z)
|
||||
\end{lstlisting}
|
||||
|
||||
is correctly evaluated as having the type \( \forall \texttt{a}\ \texttt{b}, (\texttt{Int} \to (\texttt{Bool}, \texttt{a}) \to (\texttt{b}, \texttt{a}) \to \texttt{a}) \to \texttt{Int} \to (\texttt{Bool}, \texttt{a}) \to (\texttt{b}, \texttt{a}) \to \texttt{a} \).
|
||||
\end{section}
|
||||
%%% Local Variables:
|
||||
%%% TeX-command-extra-options: "-shell-escape"
|
||||
%%% TeX-master: "document.tex"
|
||||
|
||||
Reference in New Issue
Block a user