Comment by abeppu
2 days ago
I'm dimly aware that the Hindley-Milner system is closely related to System F and that System F has many notable exceptions on of the most significant of which is System F<: (System F-sub), which I thought was the subject of a number of inference papers in the 80s and 90s.
What's the difference between that work decades ago and the work from Stephen Dolan in 2016 cited in this post? Like, what's the thing that is demonstrated now that we didn't have like 30 years ago?
Briefly, algebraic data types add polarity to the types so that we don't have both S <= T and T <= S, which would imply equality. Instead we have S+ <= T- and T+ <= S-. The positive types represent a value source and the negative types are a sink. For example, in a function call, the args are negative and the return type is positive. Inside the function its formal parameters become positive and its return type is negative. Variables exist in an "ambipolar" state which can be both the source or the sink, depending on whether we're using it on the rhs or lhs of an assignment.