Note. This question is somewhat related to my previous one , but it really touches on the problem from different points of view.
Consider the 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
While the function strOpuses what seems like a more elegant solution, and can also convert the unit value to a string, it does not seem to be really universal, as its type becomes limited during first use (even the type is inferred obj -> string, not 'a -> string)
Why doesn't the string operator work in this general way? Or am I doing something wrong?
source
share