4 ms·
Can we please just do Hindley-Milner? They knew all this stuff in the 1970s...
by gaius 12y ago
Can we please just do Hindley-Milner? They knew all this stuff in the 1970s...
- berdario 12y agoScala 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/ http://ericlippert.com/2012/11/09/dynamic-contagion-part-two... )
- bjz_ 12y agoIt would be nigh impossible to retrofit in a backwards compatible way. :(
- gaius 12y agoThe Python community is fine with that, in major versions.
- indosauros 12y agoNot likely anymore: http://www.curiousefficiency.org/posts/2014/08/python-4000.html http://www.curiousefficiency.org/posts/2014/08/python-4000.h...
- andreasvc 12y agoThat'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.
- emu 12y agoYou 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 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.
- freyrs3 12y agoStrictly 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.
- ufo 12y agoThe 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.
- tree_of_item 12y agoNo, we can't, HM type inference is for nonunion, nondependent types. Python is of course going to need unions due to its dynamic nature.
- sitkack 12y agoLook at Shedskin and the papers it references.
- sitkack 12y agohttps://gist.github.com/anonymous/127a99a05058afabddfc https://gist.github.com/anonymous/127a99a05058afabddfc