This project implements a type checker for Standard ML with polymorphic recursion, which infers most general types in the Milner-Mycroft rather than the Hindley-Damas-Milner type system.
Since Milner-Mycroft typability is generally undecidable, the implementation allows the user to switch between these type systems. The aim is to gain some experience with the Milner-Mycroft system in practice, and test the conjecture that `hard' examples of type inference do not arise in actual programming.
Examples and future applications of polymorphic recursion.
gunzip -c polyrec.093.tar.gz | tar xvf -This creates a subdirectory polyrec; follow the install notes there.
Semiunification type constraints are represented as simple lists of type inequations, which are solved on typing recursive definitions. The representation could be improved (i) by using the semiunification graphs of F.Henglein and (ii) by storing properties of individual and type variables in attributes of these variables. But this would need a delicate combination with type unification in the existing compiler and some changes in fundamental datatypes of the existing compiler of SML of New Jersey.
To install SML/NJ Version 110 [Poly Rec], unpack the file in the root directory of your SML distribution. You need the compilation manager CMB included in the distribution of SML/NJ Version 110 (target sml-full-cm of config/targets).
Uncompressing this file with tar xvzf sml-polyrec-x86bin.tgz creates two subdirectories: a directory polyrec containing the documentation files and source code, and a directory bin containing
bin/.arch-n-opsys bin/.run/ bin/.run/run.x86-linux bin/.heap/ bin/.heap/smlpr.x86-linux bin/smlpr bin/.run-smlEdit the file bin/.run-sml by setting its BIN_DIR variable to the subdirectory bin of the directory where you unpacked sml-polyrec-x86bin.tgz. To run sml-polyrec, call bin/smlpr.
Only the latest version 1.5 of Poly Rec has been adapted to SML/NJ Version 110. The correctness proof was made for version 1.3; the later version is simpler and more efficient due to a different representation of type inequation constraints. (Directory doc of polyrec.110.tar.gz also includes the correctness proof etc.)
Two provisos have to be made:
If the defining expression t of a recursive function f has principal type ty1 -> ... -> tyN and tyN is a type variable(!), then f must not be used in t with some instance ty1' -> ...-> tyN' where tyN' is (ty -> ty'). Thus, the arity of f in t must not exceed the one of the defining expression (a natural restriction that seems to exclude nonterminating functions only). For example,
fun f x = f f xis rejected. We have not yet incorporated an arity check into Poly Rec, so you will recieve a compiler bug:
Error: Compiler bug: LambdaType: unexpected case in tcd_arw
Acknowledgement This project has been supported by the Deutsche Forschungsgemeinschaft and by ESPRIT Basic Research Action GENTZEN.
Martin Emms, firstname.lastname@example.org
Hans Leiß, email@example.com
Centrum für Informations-
und Sprachverarbeitung (CIS)
Created: Mon Mar 16 18:30:06 MET 1998
Last modified: Mon Oct 15 11:21:10 MET 2001