CSC448: Type Checking Revisited: Type Inference [114/133] |
Type inference can help developers using functions or methods that exhibit generic polymorphism.
We will look at type inference for a simple functional language. See section 6.6 of the Dragon book for more details.
The type inference process subsumes type checking: if the type inference mechanism returns a type, then the expression must be well-typed.
In addition, we should infer the most general type possible.
For example, we would be unhappy if the type inference
process found the type int list -> int list
for
reverse
and refused to allows its use on lists
of strings.