Hacker News new | past | comments | ask | show | jobs | submit login

Can we please just do Hindley-Milner? They knew all this stuff in the 1970s...



You are confusing two different things: gradual typing, and type inference.

Type inference infers a static type for every expression in a program. Hindley-Milner is such a type inference algorithm.

Gradual typing allows you to partition your program into typed and untyped parts. The untyped parts need not even be typable under your type system.

Type inference and gradual typing can be combined. See: Siek and Vachharajani: Gradual typing with unification-based inference http://dl.acm.org/citation.cfm?id=1408688

The idea of that paper is that you want to do type inference for the statically typed part of your program in a gradual type system.


Strictly speaking Hindley-Milner is the type system that itself admits tractable inference using the usual unification techniques via the Damas-Milner family of algorithms. Gradual typing itself uses type inference in the Damas-Milner family, although it diverges with it's notion of consistency.


Scala doesn't/cannot use Hindley-Milner, I doubt it could be any easier to apply it to Python. (Clojure core.typed doesn't use hindley milner either afaik. There've been experiments on that front though)

Also, type inference doesn't mix very well with dynamic types ("dynamic is viral", or similar things, I've briefly skimmed this post and I think it makes the point: http://ericlippert.com/2012/11/09/dynamic-contagion-part-two... )


The problem is that HM doesn't integrate super well with dynamic typing. They already tried doing that with Scheme a while ago (search for Soft Typing) but the end result was very complex and hard to use.


No, we can't, HM type inference is for nonunion, nondependent types. Python is of course going to need unions due to its dynamic nature.


That's false. This is gradual typing, which is more recent. Gradual typing allows dynamicity, while HM fails if not every type can be statically inferred. Furthermore, IIRC there are reasons why HM is less/not suited for imperative languages, but they escape me at the moment.


It would be nigh impossible to retrofit in a backwards compatible way. :(


The Python community is fine with that, in major versions.



Look at Shedskin and the papers it references.





Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: