How the OCaml type checker works (2022)
okmij.org
okmij.org
The very first sentence was: > There is more to Hindley-Milner type inference than the Algorithm W.
I guess congratulations to the author for knowing the audience well enough
So, in fact, it's actually never algorithm W in non-toy languages. ;)
Side note: this article is originally from 2013 and is considered a must-read by any would-be hackers trying to modify the OCaml typechecker (it's cited in the documentation).
> As it stands, W is hardly an efficient algorithm; substitutions are applied too often. It was formulated to aid the proof of soundness. We now present a simpler algorithm J which simulates W in a precise sense.
I'm actually a bit surprised that it took so long to discover these formulations of unification. I wonder what Prolog systems were doing at the time, given the importance of efficient unification.
https://en.m.wikipedia.org/wiki/Hindley%E2%80%93Milner_type_...
The level tracking reminds me of a recent paper exploring SimpleSub[0], a simpler alternative of adding subtyping to ML-style type systems. It also gets rid of the algorithm W's repeated generalization (introducing foralls and turning a type into a polytype) and instantiation (changing the universally quantified type variables to fresh type variables). They have slightly different operations on levels, e.g. extrude. I wonder if this level tracking is independently invented again.
Setting a static max-width, increasing margins, and playing with the font made the page much more readable for me.
I suspect that Gleam is quite different in that regard.
As for the GC systems language, there is even a book about it,
The Haskell's STM and channels implemented in it allow for most (or all) of the Go "select" statement, but in a library, not language.
Haskell is more like a Rust of FP. But Rust is also much more pragmatic than Haskell.
OCaml is in many ways a sane Typescript or a functional version of Go.
Basically, it seems, it's Erlang for OCaml. Hot reloading would be a cool feature, though, but I can see why it's not implemented, at least not yet.. I recall the OCaml native toplevel is able to load code in dynamically, so that could be the mechanism to do it.
It seems to use open types for handling messages (per just looking at https://github.com/riot-ml/riot/tree/main/examples/3-message...) reducing the benefits of exhaustiveness checking, but it still seems rather interesting!
A more nuanced answer is that many problems are reducible to SAT, meaning that the answer can technically be yes, but a type checker that simply prints the message “UNSAT” upon failure isn’t very useful!