Type variables
. Variables can be used in type expressions to represent unknown types
. Important use: check consistent use of an identifier in a language that does not require identifiers to be declared
. An inconsistent use is reported as an error
. If the variable is always used as of the same type then the use is consistent and has lead to type inference
. Type inference: determine the type of a variable/language construct from the way it is used
- Infer type of a function from its body
Type inference is the problem of determining the type of a statement from its body:
. Similar to type checking and coercion.
. But inference can be much more expressive when type variables can be used.
|