I just learned that OCAML have to have a .
postfix for doing float arithmetic. An example would be 3. +. 4.
which equals 7.
(float). H
Briefly, F# has an ad-hoc-overloading mechanism via the inline
keyword and "static member constraints". There is some further magic specific to the built-in math operators, which magically assumes type int
the absence of other constraints. (+)
is just about the most special/magical thing in all of F#, so it does not make for a nice introduction to the language/type system.
In general, "overloading" is difficult for statically-typed, type-inferred languages. F#'s choices here are very pragmatic. OCaml does a different, simple, pragmatic thing (no overloading). Haskell does a different, complex-but-elegant thing (type classes). They're all somewhat reasonable points in the language/library design space.