Type inference is a faculty some programming languages, most notably Haskell and ML, have to infer principal types from terms without requiring explicit type annotations. There are, in some cases, terms in Haskell that can be well-typed but which have no principal type. In those cases, an explicit type annotation must be added.
The principle type is the most generic type that still type checks. Principal typing holds for that type system if a type can be found for a term in an environment for which all other types for that term are instances of the principal type. Given the inferred types:
a
Num a => a
Int
The principal type here is the parametrically polymorphic a.
Type inference is a faculty some programming languages, most notably Haskell and ML, have to infer principal types from terms without requiring explicit type annotations. There are, in some cases, terms in Haskell that can be well-typed but which have no principal type. In those cases, an explicit type annotation must be added.
The principle type is the most generic type that still type checks. Principal typing holds for that type system if a type can be found for a term in an environment for which all other types for that term are instances of the principal type. Given the inferred types:
The principal type here is the parametrically polymorphic
a
.Given these types:
The principal type is
(Ord a, Num a) => a