Our great sponsors
-
write-you-a-haskell
Building a modern functional compiler from first principles. (http://dev.stephendiehl.com/fun/)
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
While trying out the excellent tutorial on HM type inference https://github.com/wh5a/Algorithm-W-Step-By-Step I noticed that this implementation does not support recursive let bindings ("letrec"), which are necessary for example for implementing "fix".
This is the best resource I know of: http://dev.stephendiehl.com/fun/006\_hindley\_milner.html https://github.com/sdiehl/write-you-a-haskell/blob/master/chapter7/poly_constraints/src/Infer.hs
If you’re interested, you can find the code that does this somewhere in GHC. (I couldn’t tell you where to look off the top of my head, but I distinctly remember successfully looking for it a couple of years ago. I wanted to add a HM type system to my toy Prolog interpreter and I had this exact question!)
Related posts
- A decade of developing a programming language
- Can one use lambda calculus as an IR?
- First (1/5) steps with HVM, A massively parallel, optimal functional runtime in Rust
- meet typeless, an interpreter for λ-calculus implemented in ruby
- meet typeless, an interpreter for untyped λ-calculus implemented in ruby