Hindley-Milner type inference with constraints

- January 2, 2017
Kwang's Haskell Blog - Hindley-Milner type inference with constraints

Hindley-Milner type inference with constraints

Posted on January 2, 2017 by Kwang Yul Seo

Algorithm W is the best known algorithm for implementing Hindley-Milner type inference. But it is a bit complicated as it intermingles two separate processes: constraint generation and solving.

There is an alternative approach based on constraints generation. In this approach, constraints are collected by bottom-up traversal, and then solved independently. Heeren’s Generalizing Hindley-Milner Type Inference Algorithms paper describes the algorithm in details.

Here’s my implementation of Heeren’s algorithm. I forked Stephen Diehls’s Poly and modified the type checker to use the Heeren’s algorithm.

Read more

Type inference algorithms of Haskell-like languages

- December 31, 2016
Kwang's Haskell Blog - Type inference algorithms of Haskell-like languages

Type inference algorithms of Haskell-like languages

Posted on December 31, 2016 by Kwang Yul Seo

I collected papers on the type inference algorithms used by Haskell-like languages.

Haskell

Haskell supports advanced type system features such as GADTs, type classes and type families. The current type checker implemented by GHC is described in OutsideIn(X): Modular type inference with local assumptions.

PureScript

The type checker of PureScript is inspired by the following papers. It supports type classes, row polymorphism, higher kinded polymorphism (rank N types). There are no soundness proofs yet.

Elm

Elm’s type checker is an implementation of Pottier and Rem’s The Essence of ML Type Inference with two extensions:

There is no support for type classes or higher kinded polymorphism yet.

Read more