Note: This question is somewhat related to my previous one, but it actually touches the issue from different perspective
Consider following snippet:
let toStr a = a.ToString()
let strOp a = string a
let intToStr = 5 |> toStr
let floatToStr = 5.0 |> toStr
let intStrOp = 5 |> strOp
let floatStrOp = 5.0 |> strOp //type inference error
While the strOp function uses what appears to be more elegant solution, and is able to convert a unit value to string as well, it seems not to be truly generic since it's type gets constrained during it's first usage (even the type inferred is obj -> string, not 'a -> string)
Why doesn't string operator work in such a generic way? Or am I doing something wrong?
let inline strOp a = string a- user4003407toStris a true generic function, whereasstrOpinstantiates an inline function with statically resolved type constraints, but is not itself inline, so doesn't carry over the genericity. This may help in explaining the details: stackoverflow.com/questions/30445828/… - Fyodor Soikin