What are the limits of type inference?

喜夏-厌秋 提交于 2019-12-03 05:48:52

问题


What are the limits of type inference? Which type systems have no general inference algorithm?


回答1:


Joe Wells showed that type inference is undecidable for System F, which is the most basic polymorphic lambda calculus, independently discovered by Girard and Reynolds. This is the most important result showing the limits of type inference.

Here's an important problem that is still open: what is the best way to integrate Generalized Algebraic Data Types into Hindley-Milner type inference? Every year Simon Peyton Jones comes up with a new answers, which is supposedly better than the previous year's answer. I haven't read the March 2009 version and so can't say if I believe it will be definitive.




回答2:


A value-dependent-type system (Or in short, dependent type system) can describe types that say things like: "At evaluation time (runtime), the value of this variable will always be equal to the value of that variable, which is computed with a different evaluation process". Automatically deducing this type from the code entails automatic proofs of theorems. If the set of theorems you can express is restricted to those automatically provable, that would not be a problem, but in the case of dependently-typed languages, this is generally not the case.

So dependently typed systems cannot have general (and complete) type inference.

I am sure someone can provide a moral formal and complete answer...



来源:https://stackoverflow.com/questions/1251254/what-are-the-limits-of-type-inference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!