Foundationপ্রথম নীতি থেকে
LEVEL 5 · Programming Languages

Hindley-Milner

হিন্ডলি-মিলনার

Annotation ছাড়াই full type inference-এর algorithm (Algorithm W) — unification দিয়ে ML-family ভাষার let-polymorphism বের করে।

fun x -> x লিখলেই checker বলে ∀a. a → a — annotation শূন্য:

let id x = x            (* 'a -> 'a *)
let r = id 1, id true   (* int * bool — দুই instantiation *)
  • Engine তিনটা: fresh variable (assumption), unify (constraint মেলানো), generalize/specialize (let-এ polymorphism)
  • Occurs-check infinite type (t = t→t) আটকায় — Y-combinator reject হওয়ার কারণ
  • Principal types guarantee: যে type পাওয়া যায়, সেটা most general
  • Limitation: rank-N polymorphism আর higher-rank function-এ W হার মানে — OCaml/Haskell সেখানে annotation চায়