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.
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. Inclusion test: Include HM-style generalization at let and fresh scheme instantiation at occurrences under declared restrictions. Exclusion test: Exclude ad hoc overloading, subtype polymorphism, explicit higher-rank quantifiers, and lambda-bound parameters generalized as if let-bound. Nearest boundary: Parametric polymorphism is broader; let polymorphism names this binding-specific introduction and use discipline. Exit condition: The mechanism exits when a binding remains monomorphic or uses share one unrefreshed type variable. Common misclassifications: 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. Nearest named distinctions: Parametric polymorphism: The broader uniform-type idea. Monomorphism: Uses one fixed type. Overloading: Selects type-specific behavior. Higher-rank polymorphism: Allows nested explicit quantification.
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.
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.
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