Simple Bidirectional Type Inference
ettolrach.com·1d·
Preview
Report Post

Written by ettolrach, 2025-12-23.

Most commonly-used programming languages don’t use a well-known algorithm for their type inference. A few languages use Hindley-Milner type inference, such as Rust, Haskell, and F#.

Another algorithm which isn’t used by any popular languages (to my knowledge) is called bidirectional type inference. In contrast to Hindley-Milner, it’s supposed to be easier to implement and gives better error messages with the drawback of being more difficult to understand and to start with.

[Update 2025-12-30: I’ve since been shown that Swift uses a bidirectional algorithm! So I stand corrected.]

There aren’t a lot of tutorials out there, especially ones that are designed for someone who d…

Similar Posts

Loading similar posts...