When defining a simple function that takes the square of a value, SML NJ infers the signature for this function to integer types. When declaring the signature for float types, SML can work with floating point values here.
- fun sqr x = x * x; val sqr = fn : int -> int - fun sqqr (x : real) = x * x; val sqqr = fn : real -> real - sqqr 3.4; val it = 11.56 : real
- Why and how does SML infer this specific type here?
- Is there a specific preference for ints?
- Is this special behaviour for these arithmetic operations or can it be found in other places?