I would like to overload the (/) operator in F# for strings and preserve the meaning for numbers.
/// Combines to path strings
let (/) path1 path2 = Path.Com
I do not think this is possible in F#, based on a reading of the overloading documentation.
I would instead suggest that you create your own function which looks like /
but isn't. Something like:
let (>) path1 path2 = Path.Combine (path1,path2)
This is likely to be less annoying in the long run because it doesn't mess with the implicit type inference that the human reader is running--/
means that the result is a floating point, and remembering that it's sometimes a string is a burden*. But after the first time the reader sees >
, it's easy to remember that it does something related to the symbol embedded in the middle.
*I think the only reason +
for strings looks OK is over-exposure. After using Haskell or Caml for a long time, the first few minutes after switching to another language makes "foo" + "bar"
look jarringly bad.