Typetool [1] is a web
application developed at the University of Porto - Department of Computer
Science and LIACC for the visualization of type derivation trees.
The application works for the Simple Type System [2,3] for the lambda-calculus and for the Damas-Milner Type System [4] for pure ML.
The Simple Type System is the basis of every type system for the lambda-calculus.
The Damas-Milner Type System is the basis of polymorphic systems for functional programming languages such as ML or Haskell.
Implementation
The implementation was made in Prolog and CHR along the lines presented in the paper Type Inference using Constraint Handling Rules [5].
Type Systems
The Simple Type System parser accepts lambda terms following the Haskell syntax:
M ::= x | \x1 ... xn -> M | M1 M2 | (M)
The Damas-Milner Type System parser accepts lambda terms with the same syntax and some programming language constructs such as integers, booleans, conditionals and a fixpoint operator, Y:
M ::= let x = M1 in M2
M ::= M1+M2 | M1-M2 | M1*M2 | M1/M2 | M1%M2 | -M | n
For the Damas-Milner Type System, the types of free variables must be declared (one per line) as initial assumptions, before the term. An assumption follows the syntax:
Assumption ::= Variable '::' Type
Type ::= Constant | Variable | Type -> Type | forall Variable . Type
Type variables start with a lowercase letter (a-z) and type constants start with an uppercase letter (A-Z)