Is there any type inference algorithm that can always (or almost always) infer the correct type? I know that the Hindley Milner algorithm can do it in quite a bit of cases but not all of them (i.e., higher-rank polymorphic types).
Is there any type inference system that works in all cases?
148 Views Asked by xilpex At
1
There are 1 best solutions below
Related Questions in ALGORITHM
- new thread blocks main thread
- Extracting viewCount & SubscriberCount from YouTube API V3 for a given channel, where channelID does not equal userID
- Display images on Django Template Site
- Difference between list() and dict() with generators
- How can I serialize a numpy array while preserving matrix dimensions?
- Protractor did not run properly when using browser.wait, msg: "Wait timed out after XXXms"
- Why is my program adding int as string (4+7 = 47)?
- store numpy array in mysql
- how to omit the less frequent words from a dictionary in python?
- Update a text file with ( new words+ \n ) after the words is appended into a list
Related Questions in TYPE-INFERENCE
- new thread blocks main thread
- Extracting viewCount & SubscriberCount from YouTube API V3 for a given channel, where channelID does not equal userID
- Display images on Django Template Site
- Difference between list() and dict() with generators
- How can I serialize a numpy array while preserving matrix dimensions?
- Protractor did not run properly when using browser.wait, msg: "Wait timed out after XXXms"
- Why is my program adding int as string (4+7 = 47)?
- store numpy array in mysql
- how to omit the less frequent words from a dictionary in python?
- Update a text file with ( new words+ \n ) after the words is appended into a list
Related Questions in HINDLEY-MILNER
- new thread blocks main thread
- Extracting viewCount & SubscriberCount from YouTube API V3 for a given channel, where channelID does not equal userID
- Display images on Django Template Site
- Difference between list() and dict() with generators
- How can I serialize a numpy array while preserving matrix dimensions?
- Protractor did not run properly when using browser.wait, msg: "Wait timed out after XXXms"
- Why is my program adding int as string (4+7 = 47)?
- store numpy array in mysql
- how to omit the less frequent words from a dictionary in python?
- Update a text file with ( new words+ \n ) after the words is appended into a list
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Your question isn't entirely well-posed, because the set of "all cases" isn't entirely well-defined.
For example, you mention higher-rank polymorphic types as a case where Hindley–Milner type inference can't always infer the right type, which is true, except that there are languages such as Standard ML and Haskell that use Hindley–Milner type inference and don't have higher-rank polymorphic types. In fact, Hindley–Milner algorithms do work in all cases covered by the Hindley–Milner type system; that is, the Hindley–Milner system allows exactly the types that can be inferred by Hindley–Milner type inference algorithms, and explicit type annotations are therefore never needed in that system.
Of course, real-world languages using Hindley–Milner typically extend the system in various ways for pragmatic reasons, and some of those extensions result in cases that the algorithm doesn't cover. (For example, Standard ML has some built-in overloaded identifiers, such as
+ : real * real -> real
and+ : int * int -> int
, which means that programmers sometimes need to use explicit type annotations in order to choose the right overload.) But that is a design decision, not a necessity; and I notice that you don't mention any real-world languages in your question, anyway.But it seems from your question that you want at least all of Hindley–Milner plus higher-rank polymorphic types. That means that you want at least all of System F, the polymorphic lambda calculus. And type inference in System F is known to be undecidable. This means that the answer to your question is "no": no type inference algorithm can infer the correct types for all the cases you seem to want.