Type inference for objects

Type inference. Types are useful because they can help a compiler generate good code and because “well-typed programs cannot go wrong.” In languages such as Pascal and Ada, variables must be declared with a type, and the compiler can then verify whether a given program is indeed well-typed. This verification is called type checking. Type inference is the computation of missing type annotations. It allows us to omit some or all of the type annotations in our programs, and it is successfully used in functional languages such as ML and Haskell.