3 ms·
> Why don’t we have to write types in ReasonML? Because of the powerful type system that allows for incredible type inference. You mean the restricted type sys
by tomp 7y ago
> Why don’t we have to write types in ReasonML? Because of the powerful type system that allows for incredible type inference.
You mean the restricted type system that allows for principal type inference? ML's type system is much less powerful than Haskell's or Scala's, precisely to allow type inference (e.g. no overloads). The type inference itself isn't very powerful or incredible either, it works just for the exact type system offered by ML.
Obviously nobody likes this, which is why ML offers a number of hacks to allow more powerful type system hackery - e.g. open sums ("polymorphic variants" and also open exception types), HKTs (modules), GADTs, row types & subtyping (objects). Although IMO it would be better to incorporate all these hacks in the core language itself, and only run type inference on the bits where it's possible (but of course tradeoffs would be necessary to avoid running into halting problems etc.).
- sweeneyrod 7y agoYes, that sentence should've probably been "Why don't we have to write types in ReasonML? Because of the powerful type inference system". But I think comparing to Haskell is kind of missing the point: you can't use that for front-end web development. Also, I'm not sure what you mean by saying those "hacks" aren't part of the core language.
- tomp 7y agoBy “hacks” I mainly meant that they don’t play that nice with type inference... type annotations are sometimes needed. Also that they were added to the language later, in order to make the type system more powerful.
- ernst_klim 7y ago> number of hacks These are not hacks, subtyping and GADT are part of the core language > ML's type system is much less powerful than Haskell's or Scala's Yes, but most of the fancy stuff is located in the module language, and it doesn't lack power, it lacks implicitness (until modular implicits would land).
- yawaramin 7y ago> ML's type system is much less powerful than Haskell's or Scala's That's arguable. What's not arguable is that every OCaml compiler runs circles around GHC and scalac in terms of compilation speed. If you like not waiting for the compiler, then you should like OCaml.