Here's code that works fine:
let f x y z = x + y + z
let g x y = f x y
let h x z = z |> f x
So I can write expression "h 1", and FSI displays:
val it : (int -> int -> int) = <fun:it@110-3>
If I call "h 1 2 3", the arguments are applied in the right order.
But if the last argument has a different type, things get different:
let ff x y (z : string) = x + y
let gg x y = ff x y
let hh x (z : string) = z |> ff x
Now the last function hh causes an error message:
Script.fsx(119,10): error FS0001: Type mismatch. Expecting a
string -> 'a
but given aint -> string -> int
. The typestring
does not match the typeint
I understand why this happens - "z" is appended to "ff x" making it a second argument. But then I'd expect in the first example expression "h 1 2 3" not to work properly (being executed as "f 1 3 2"). But it works just fine.