syntax - Small difference in types -
i have 3 functions ought equal:
let add1 x = x + 1 let add2 = (+) 1 let add3 = (fun x -> x + 1) why types of these methods differ?
add1 , add3 int -> int, add2 (int -> int). work expected, curious why fsi presents them differently?
this typically unimportant distinction, if you're curious, see arity conformance values section of f# spec.
my quick summary (int -> int) superset of int -> int. since add1 , add3 syntactic functions, inferred have more specific type int -> int, while add2 function value , therefore inferred have type (int -> int) (and cannot treated int -> int).
Comments
Post a Comment