Questions tagged [hindley-milner]

In type theory, Hindley–Milner (HM) is a classical type inference method with parametric polymorphism for the lambda calculus.

In , Hindley–Milner (HM) is a classical type method with for the lambda calculus.

One property that makes the Hindley-Milner type theory important is its completeness and its ability to deduce the most general type of a given source without the need of any type annotations or other hints. HM is a fast algorithm that can compute a type almost in linear time with respect to the size of the source, which makes it of practical use for the types of large programs. HM is used for several functional programming languages. It was first implemented as part of the type system of the programming language . Since then, HM has been extended in various ways, most notably by constrained types as used in , which it has a strong association with.

The original paper

A Theory of Type Polymorphism in Programming

Languages implementing Hindley-Milner

See also

84 questions
1
vote
0 answers

Type checking algorithm for tuple in let expression

This block gives f = let (x1, x2, x3) = (\y1 -> (y1, y1), \y2 -> x1 (x1 y2), \y3 -> x2 (x2 y3)) in x1 error: Occurs check: cannot construct the infinite type: t1 ~ (t1, t1) Relevant bindings include y2 :: t1 (bound at test.hs:1:43) x1 :: t1…
Ganesh Bhambarkar
  • 930
  • 1
  • 8
  • 9
0
votes
1 answer

[F#][Type inference] - How to improve my program?

I'm currently building a program to type inference in F# using the following AST: // errors // exception SyntaxError of string * FSharp.Text.Lexing.LexBuffer exception TypeError of string exception UnexpectedError of string let…
Marc
  • 38
  • 1
  • 7
0
votes
0 answers

Hindley-Milner - conditional Substitutions?

I have been trying to build a type system with the Hindley-Milner Algorithm and ran into the following challenge and was curious if there are any resources or papers out there I can take a look at. Suppose I have a programming language that has some…
0
votes
1 answer

Can someone explain how to unify types(Haskell)?

Can someone explain type unification in Haskell? For example: snd . snd :: (a1, (a2, c)) -> c Example How do we get to, (a1, (a2, c)) -> c, from snd . snd? Thanks in advance for the help.
xyz123
  • 1
0
votes
1 answer

Is there any type inference system that works in all cases?

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).
xilpex
  • 3,097
  • 2
  • 14
  • 45
0
votes
1 answer

Can type inferer detect type errors?

I am developing a interpreter of a functional programming language, which uses Hindley-Milner type system. The question is, where should type errors occur(be detected)? For example, if I apply Integer type value to a function that has type Bool ->…
0
votes
1 answer

Haskell / Parsec - commenting out parseFromFile call leads to ambiguous types

I'm working on some parsec code. At the bottom of the script, there's a parseFromFile call, where ParseFromFile comes from Text.Parsec.String parseFromFile parserCode inFile If I comment this out, my code no longer compiles and I get a host of…
daj
  • 6,962
  • 9
  • 45
  • 79
0
votes
3 answers

What causes this Standard-ML type error?

I was trying to make a tail-recursive version of this very simple SML function: fun suffixes [] = [[]] | suffixes (x::xs) = (x::xs) :: suffixes xs; During the course of this, I was using type annotations on the paramaters. The following code…
harms
  • 8,728
  • 4
  • 30
  • 27
-1
votes
1 answer

What substitution should this unification return?

What should be the result of unifying these two types? 1) a -> a 2) Int -> b Is this the right result? { a |-> Int; b |-> a }
wpcarro
  • 1,528
  • 10
  • 13
1 2 3 4 5
6