3 ms·
> Ocaml and the MLs have a very strong commitment to global type inference, much stronger than Haskell's This is hilarious to read when (+.) is a thing in OCam
by ghostwriter 6y ago
> Ocaml and the MLs have a very strong commitment to global type inference, much stronger than Haskell's
This is hilarious to read when (+.) is a thing in OCaml
> Without saying what type "read" is supposed to return here, there's no way to know what this code is supposed to do.
It has nothing to do with global type inference, as "1" can successfully and meaningfully be parsed into several distinct types, like Int, Integer, Float, MyCustomEnum at the same time, where each of them has their own implementation of `Show`. You cannot "magically" infer that globally, unless you introduce an equivalent of (+.) for disambiguating parsing, which would serve the same purpose as the explicit type annotation passed to the parser.