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
- MCNP 6 - Doubts about cells
- Given partially sorted array of type x<y => first apperance of x comes before first of y, sort in average O(n)
- What is the algorithm behind math.gcd and why it is faster Euclidean algorithm?
- Purpose of last 2 while loops in the merge algorithm of merge sort sorting technique
- Dots and Boxes with apha-beta pruning
- What is the average and worst-case time complexity of my string searching algorithm?
- Building a School Schedule Generator
- TC problem 5-2:how to calculate the probability of the indicator random variable?
- LCA of a binary tree implemented in Python
- Identify the checksum algorithm
- Algorithm for finding a subset of nodes in a weighted connected graph such that the distance between any pair nodes are under a postive number?
- Creating an efficent and time-saving algorithm to find difference between greater than and lesser than combination
- Algorithm to find neighbours of point by distance with no repeats
- Asking code suggestions about data structure and algorithm
- Heap sort with multithreading
Related Questions in TYPE-INFERENCE
- Typescript: how to get possible keys from const with limited values?
- How to Make TypeScript Infer Object Fields in a Tuple Return Type Based on Conditions?
- Is there a way to infer the keys of a mapped type when using Typescript?
- TypeScript: ignore function signatures from inherited classes
- How to correctly give restrictions to typescript generics
- Why can't typescript infer these correlated types?
- Why do I need an explicit downcast in an exhaustive switch expression?
- Type information system recovery
- Constrain Generic Parameter to ICollection with Varying Element Types
- Is type checking required for languages with full type inference (without type annotations)?
- Why can't SBCL determine the upgraded-array-type of elements of a string at compile-time?
- MyPy does not recognise x[idx] as boolean after isinstance(x[idx], bool)
- TypeScript infer value type based on a passed key
- Why is Type Inference not applied?
- is there a way in ts to just restrict key of the object during generic infer?
Related Questions in HINDLEY-MILNER
- What substitution should this unification return?
- [F#][Type inference] - How to improve my program?
- How to comprehend Algorithm W in Hindley–Milner type system?
- Characterizing the type of functions that can accept `()` as input (without monomorphizing)
- Can a type statically guarantee that a function to pairs only partially depends on its input?
- Are function parameters not polymorphic in Algorithm W (or Haskell)?
- Reasoning about types in Haskell
- How can I infer types for recursive functions?
- How to represent functions with multiple arguments in Hindley-Milner?
- What is the best algorithm for Hindley Milner type inference when one wants to optimize for error messages
- How to interpret this Ramda signature?
- How does Haskell perform Beta conversion to derive a type?
- Unification of applicators with different arity through substitution
- Generalized HM vs. Higher-Order Unification
- Can Hindley-Milner return more than one error?
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 -> 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.