Actually, f = function... is a shortcut to f (x, y) = match (x, y) with... , therefore:
let f = function | pattern1_of_x_y -> expr1 | ...
matches with:
let f (x, y) = match x, y with | pattern1 -> expr1 | ...
(Note that there is a mistake in the second wording, these two versions are incompatible).
As you pointed out, you cannot use match ... with... in a curry function. Personally, I prefer the currency form of the function, since it is more flexible, especially with partial use. Moreover, pattern matching is used not only in function arguments; they are used almost everywhere in OCaml, which makes the match ... with... construct even more important.
Whenever you specify a usage pattern as above, try replacing match ... with... with function . It's just a matter of style, so there is nothing more preferable here.
pad
source share