Is there a way to extract member functions, and use them as F# functions? I’d like to be able to write the following:
mystring |> string.Split '\n' |> Array.filter (string.Length >> (=) 0 >> not)
The code above works if you [let]
let mystring = "a c\nb\n"
let stringSplit (y:char) (x:string) = x.Split(y)
let stringLength (x:string) = x.Length
mystring |> stringSplit '\n' |> Array.filter (stringLength >> (=) 0 >> not)
This is quite similar to a question I asked a few days ago (but your wording is better). The consensus seems to be:
string#Split,"foo"#Split, or just#Split(type-inferred) will be added in the future. But Don Syme’s proposal that Tomas linked to was from 2007, so I don’t know how likely it is to happen–probably about as likely as a specific syntax for laziness, I’d guess.Edit:
I guess
"foo"#Splitcould also be written asstring#Split "foo". I guess it depends how flexibly you define the#syntax.