In F #, I can combine strings with an operator +like this:
let myString = "one" + "two"
But when I create a function that takes two arguments and applies the same operator, and I put it in the module declared before using it, F # writes the types as integers:
module StringFunctions =
let add str1 str2 =
str1 + str2
The call below gives me a build error: "It is expected that the expressions will be of type" int ", but there is a type of" string "here:
let str3 = StringFunctions.add "three" "four"
Why does F # issue this as an int? I assume that this cannot be a general method, because not all types will implement the operator +, but why does it accept an int?
source
share