Hacker News new | ask | show | jobs
by mrkgnao 3190 days ago
Rust uses Hindley-Milner type inference. OCaml uses Hindley-Milner. Swift apparently uses a variant of the system with more features.

None of these make use of monads or anything rooted in category theory.

https://en.wikipedia.org/wiki/Hindley%E2%80%93Milner_type_sy...

HM is a type system that also gives you an algorithm to infer types without having to do the "List<Integer> foo = new ArrayList<Integer>()" dance from languages without type inference. That's it. It has nothing to do with category theory.

2 comments

(Rust doesn't use Hindley-Milner, though the plan is to try to move closer to it in the future)
Oh, thanks for the correction.

It would appear that my knowledge is out of date: did Rust use something closer to H-M in the past? (Going off of https://github.com/rust-lang/rust/pull/15955 here.)

For more, see here: https://www.reddit.com/r/rust/comments/6fs5q9/language_serve... see aturon's reply about that PR/blog post.

Rust has done almost everything in the past; I wouldn't be surprised if somewhere back in there it was actually HM. :)

Arguably optionals are monadic.
Optionals are also "applicative", but Haskellers used them for a long time before applicative functors became popular. A concept can support a certain way of thinking about it without everyone needing to think that way :)
you don't need to think that way, no, but i was pretty sure that rust optionals were modeled after the maybe monad. perhaps not.
oh ok i misread your original, you were only referring to type inference. i thought you were saying none of the languages mentioned had monads.