I’ve been working on type inference this weekend, using a Hindley-Milner implementation I already had, but in Python. I did find some Go implementations on GitHub but, perhaps ironically, I find it easier to understand the Python version. I’m not fully comfortable with Go yet.

Inference is not at all complete, but basic literals and variables work, so after:

let a = 5 let b = a

`a`

is correctly an int, and so is `b`

. List literals are also correctly unified, so while `let a = [5, 6]`

works and creates a `list int`

type, `let a = [5, "nope"]`

produces an error.

This is small progress but quite encouraging. Hindley-Milner feels magical! And having implemented it for these basic cases has made me excited to keep going and finish the whole thing. Must find more time.