Re:Implementing and Understanding Type Classes (2014)
by calebh on Saturday April 28, 2018 @04:38PM
(#16949299)
Type inference for systems with subtyping is a different problem. There has been progress on this issue, most notably Stephen Dolan's thesis on "Algebraic Subtyping":
Re:Implementing and Understanding Type Classes (2014)
by catnaroek on Saturday April 28, 2018 @04:40PM
(#16949314)
Not too long was it figured out how to reconcile subtyping with type inference. However, this requires doing subtyping in a very specific way, which most users of languages with subtyping will not find pleasing. In particular, the design of the type system must pay very close attention to issues of polarity and existence of certain universal objects in the categories of types. This work caters more to designers and users of ML-style languages who want to add subtyping, than to designers and users of more traditional languages who want to add type inference.
Ex.
def fact(n: Int) = if (n == 0) 1 else n * fact(n - 1)
will fail to compile and tell you that you need to provide a return type.