Let-Polymorphism¶
Type-scheme generalization at let bindings with fresh instantiation at each use in Hindley–Milner systems.
Core Idea¶
Let polymorphism in Hindley–Milner typing generalizes eligible type variables at a let binding into a type scheme and freshly instantiates that scheme at each use, enabling one definition to serve multiple types.
let id = λx.x allows id 3 and id true through separate instantiations. A mutable reference is withheld from unrestricted generalization under a value restriction.
Structural Signature¶
Sig role-phrases:
- Bound expression — Supplies the inferred monotype. It is input. Counterfactual: No binding means no generalization point.
- Environment — Marks type variables already fixed by context. It is context. Counterfactual: Generalizing them is unsound.
- Generalization — Quantifies eligible free variables. It is operation. Counterfactual: Keeping a monotype loses polymorphism.
- Type scheme — Stores the quantified type. It is result. Counterfactual: Universal variables must remain scoped.
- Instantiation — Replaces quantified variables freshly per use. It is use. Counterfactual: Sharing one instance couples unrelated calls.
- Value/effect restriction — Limits generalization in languages with effects. It is safety. Counterfactual: Mutable references make unrestricted rules unsound.
What It Is Not¶
- It is not ad hoc overloading.
- It is not subtype polymorphism.
- It is not arbitrary higher-rank polymorphism.
- It does not generalize every expression safely.
- Closest near-miss. Parametric polymorphism is broader; let polymorphism names this binding-specific introduction and use discipline.
Scope of Application¶
- Functional languages. Types reusable local definitions.
- Type inference. Computes principal schemes.
- Language design. Adds effect restrictions.
- Programming-language theory. Studies parametricity and soundness.
Clarity¶
Include HM-style generalization at let and fresh scheme instantiation at occurrences under declared restrictions. Exclude ad hoc overloading, subtype polymorphism, explicit higher-rank quantifiers, and lambda-bound parameters generalized as if let-bound.
Manages Complexity¶
Generalization enables reuse while effects can couple supposedly independent instances. Inference finds a most general scheme within HM limits.
Abstract Reasoning¶
- Bound expression — Supplies the inferred monotype. No binding means no generalization point.
- Environment — Marks type variables already fixed by context. Generalizing them is unsound.
- Generalization — Quantifies eligible free variables. Keeping a monotype loses polymorphism.
- Type scheme — Stores the quantified type. Universal variables must remain scoped.
- Instantiation — Replaces quantified variables freshly per use. Sharing one instance couples unrelated calls.
- Value/effect restriction — Limits generalization in languages with effects. Mutable references make unrestricted rules unsound.
Knowledge Transfer¶
Generalize-at-let and instantiate-at-use transfers across HM-family languages under their value, effect, and recursion restrictions; unrestricted generalization is unsound with mutable state.
Examples¶
Applied / In Practice¶
let id = λx.x allows id 3 and id true through separate instantiations.
Mapped back: scheme → forall a.a→a.
Applied / In Practice¶
A mutable reference is withheld from unrestricted generalization under a value restriction.
Mapped back: reason → soundness.
Structural Tensions¶
T1 — Reuse versus Soundness. Generalization enables reuse while effects can couple supposedly independent instances.
Diagnostic: Does a value restriction apply?
T2 — Principal Type versus Annotation Burden. Inference finds a most general scheme within HM limits.
Diagnostic: Has a higher-rank demand entered?
Structural–Framed Character¶
Supplies the inferred monotype. Marks type variables already fixed by context. Generalization enables reuse while effects can couple supposedly independent instances.
Structural Core vs. Domain Accent¶
Replaces quantified variables freshly per use. Limits generalization in languages with effects. The mechanism exits when a binding remains monomorphic or uses share one unrefreshed type variable.
Instantiates / Related Primes¶
This entry presupposes Type System.
-
Approved root. The frozen graph retains let polymorphism without a parent edge.
-
Related — Parametric polymorphism and Monomorphism. The broader uniform-type idea. Uses one fixed type.
Relationships to Other Abstractions¶
Current abstraction Let-Polymorphism Domain-specific
Parents (1) — more general patterns this builds on
-
Let-Polymorphism presupposes Type System Domain-specific
Let-Polymorphism presupposes Type System because generalization and fresh instantiation operate inside a Hindley–Milner type system.Every reviewed Let-Polymorphism instance depends on the parent role: generalization and fresh instantiation operate inside a Hindley–Milner type system. Removing that role makes the frozen child identity undefined or changes it into a different abstraction. Type System can occur without Let-Polymorphism, so the relation is dependency rather than subsumption.
Hierarchy paths (2) — routes to 2 parentless roots
- Let-Polymorphism → Type System → Classification
- Let-Polymorphism → Type System → Constraint
Neighborhood in Abstraction Space¶
Let-Polymorphism sits in a moderately populated region (41st percentile for distinctiveness): it has near-neighbors but no dense thicket of look-alikes.
Family — Matrices, Measures & Numeric Structures (30 abstractions)
Nearest neighbors
- Type Error — 0.89
- Free Group — 0.87
- Bare Nouns — 0.87
- Continuous variable — 0.87
- Exact Quantum Polynomial Time — 0.86
Computed from structural-signature embeddings · 2026-10-08
Not to Be Confused With¶
- Parametric polymorphism. Tell: The broader uniform-type idea.
- Monomorphism. Tell: Uses one fixed type.
- Overloading. Tell: Selects type-specific behavior.
- Higher-rank polymorphism. Tell: Allows nested explicit quantification.
References¶
- Frozen Wikipedia discovery revision: https://en.wikipedia.org/wiki/Hindley%E2%80%93Milner_type_system (revision 1344708649).
- Preserved source candidate: http://web.cs.wpi.edu/~cs4536/c12/milner-damas_principal_types.pdf
- Preserved source candidate: https://web.archive.org/web/20220322134254/http://web.cs.wpi.edu/~cs4536/c12/milner-damas_principal_types.pdf
- Preserved source candidate: https://www.worldcat.org/title/combinatory-logic-vol-1-haskell-b-curry-and-robert-feys-with-two-sections-by-william-craig/oclc/769219250
- Preserved source candidate: http://www.macs.hw.ac.uk/~jbw/papers/Wells:Typability-and-Type-Checking-in-the-Second-Order-Lambda-Calculus-Are-Equivalent-and-Undecidable:LICS-1994.ps.gz
- Preserved source candidate: https://hal.inria.fr/inria-00076025/file/RR-0529.pdf
- Preserved source candidate: https://web.archive.org/web/20120324105848/http://www.cs.ucla.edu/~jeff/docs/hmproof.pdf
- Preserved source candidate: http://www.cs.ucla.edu/~jeff/docs/hmproof.pdf
- Preserved source candidate: https://www.microsoft.com/en-us/research/publication/giving-haskell-a-promotion/
The frozen Wikipedia revision is discovery provenance. The retained source set was reviewed for identity, formal or operational relation, and scope. The encyclopedia's structural synthesis is bounded to those claims; a thin authority surface is recorded as a nonblocking source-strengthening repair rather than concealed.