3 ms·
I thought the problem was related to subtyping? AFAIK the reason Scala doesn't have HM inference is because something about the existence (nominal?) subtyping m
by s4vi0r 8y ago
I thought the problem was related to subtyping? AFAIK the reason Scala doesn't have HM inference is because something about the existence (nominal?) subtyping makes it impossible/super hard to infer types that may seem obvious/easy - even with monomorphic functions.
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.
- calebh 8y agoType 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": https://www.cl.cam.ac.uk/~sd601/thesis.pdf https://www.cl.cam.ac.uk/~sd601/thesis.pdf
- catnaroek 8y agoNot 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. https://news.ycombinator.com/item?id=13781467 https://news.ycombinator.com/item?id=13781467