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?
178 Views Asked by xilpex At
1
There are 1 best solutions below
Related Questions in ALGORITHM
- Two different numbers in an array which their sum equals to a given value
- Given two arrays of positive numbers, re-arrange them to form a resulting array, resulting array contains the elements in the same given sequence
- Time complexity of the algorithm?
- Find a MST in O(V+E) Time in a Graph
- Why k and l for LSH used for approximate nearest neighbours?
- How to count the number of ways of choosing of k equal substrings from a List L(the list of All Substrings)
- Issues with reversing the linkedlist
- Finding first non-repeating number in integer array
- Finding average of an array
- How to check for duplicates with less time in a list over 9000 elements by python
- How to pick a number based on probability?
- Insertion Sort help in javascript -- Khan Academy
- Developing a Checkers (Draughts) engine, how to begin?
- Can Bellman-Ford algorithm be used to find shorthest path on a graph with only positive edges?
- What is the function for the KMP Failure Algorithm?
Related Questions in TYPE-INFERENCE
- Type inference inconsistency between toList and toBuffer
- Understand syntactic sugar for lambda expressions
- Implicit not found when omitting empty argument list
- Java interop - type inference failure with wildcard types
- Scala type inference for both a generic type and it's type parameter - why doesn't it work?
- Calling non-strict function in Scala with explicit types doesn't compile, inferred types works
- Matching on type patterns with type variables and type classes
- Type inference for (ignoring) method parameters in order to select a MethodInfo
- Swift Impossible Type Inference
- How to infer a function type parameter in a template function with a lambda passed as argument?
- Is declaring variable with type inference as effective as "classical way" of initializing variable with parenthesis after variable name?
- ToString throws NullReferenceException for unit value ()
- Type inference on ToString() vs string operator
- GADT's: Is there a reason why the weakest or strongest type is not chosen
- How to limit a type to the class of a interface and not the instance of that interface?
Related Questions in HINDLEY-MILNER
- Algorithm W using recursion schemes
- Haskell: Labeling an AST with type information using Algorithm W
- Type inference implemented in C++
- How can I infer types for recursive functions?
- Inferred type appears to detect an infinite loop, but what's really happening?
- What causes this Standard-ML type error?
- Bottom up Hindley-Milner type inference: Applying a substitution to an implicit constraint
- Simply typed lambda calculus vs Hindley-Milner type system
- Reasoning about types in Haskell
- Can someone explain how to unify types(Haskell)?
- Determine the effect of a function by its type
- Example of type in System F that is not available in Hindley Milner type inference
- Encode rank-2 polymorphism equivalent in SML
- Can Hindley-Milner return more than one error?
- Generalized HM vs. Higher-Order Unification
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 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 -> realand+ : 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.