Skip to content

Let-Polymorphism

Type-scheme generalization at let bindings with fresh instantiation at each use in Hindley–Milner systems.

Version
v1 · 2026-09-28 · History
Domain-specific #
10375
Domain group
Applied Sciences & Engineering
Origin domain
Computer Science & Software Engineering
Subdomains
Type Theory, Programming Languages → Computer Science & Software Engineering
Aliases
Let Polymorphism, ML Style Let Polymorphism

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

  1. Bound expression — Supplies the inferred monotype. No binding means no generalization point.
  2. Environment — Marks type variables already fixed by context. Generalizing them is unsound.
  3. Generalization — Quantifies eligible free variables. Keeping a monotype loses polymorphism.
  4. Type scheme — Stores the quantified type. Universal variables must remain scoped.
  5. Instantiation — Replaces quantified variables freshly per use. Sharing one instance couples unrelated calls.
  6. 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

Local relationship map for Let-PolymorphismParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.Let-PolymorphismDOMAINDomain-specific abstraction: Type System — presupposesType SystemDOMAIN

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

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

Computed from structural-signature embeddings · 2026-10-08