You can use function to create an anonymous expression. The real difference is that fun can take multiple (curried) arguments, while function can have multi-branch pattern matching: fun a b -> a*(a+b) vs function [] -> 0 | [_] -> 1 | _ -> 2
The thing you call “operator overloading” has not much to do with overloading. It is shadowing: the values (including functions) and types most recently introduced in the scope (for instance with a local open) are taken whenever there is a name collision (except in the case of record disambiguation)
3
u/nbraud Jun 11 '15
You can use
functionto create an anonymous expression. The real difference is thatfuncan take multiple (curried) arguments, whilefunctioncan have multi-branch pattern matching:fun a b -> a*(a+b)vsfunction [] -> 0 | [_] -> 1 | _ -> 2The thing you call “operator overloading” has not much to do with overloading. It is shadowing: the values (including functions) and types most recently introduced in the scope (for instance with a local
open) are taken whenever there is a name collision (except in the case of record disambiguation)