Google News
logo
F# - Interview Questions
What is Automatic Generalization in F#?
If the function code is not dependent on the type of a parameter, the compiler considers the parameter to be generic. This is called automatic generalization, and it can be a powerful aid to writing generic code without increasing complexity.
 
For example, the following function combines two parameters of any type into a tuple.
let makeTuple a b = (a, b)
The type is inferred to be
'a -> 'b -> 'a * 'b
Advertisement