🤖 AI Summary
Haskell’s type-class overloading lacks a unified, formal semantics, hindering rigorous reasoning and implementation. Existing approaches—relying on dictionary passing or ad hoc type-equality axioms—fail to cleanly encode advanced features such as multi-parameter type classes, functional dependencies, and associated types.
Method: We introduce System F$_mathrm{D}$, a core calculus that models overloading natively via *open data types* and *open functions*, eliminating the need for external type-equality axioms.
Contribution/Results: System F$_mathrm{D}$ fully and faithfully encodes Haskell’s type-class system, including higher-order extensions. Its metatheory—including type safety and semantic consistency—is fully mechanized in Lean 4. Compared to prior systems, System F$_mathrm{D}$ offers greater expressiveness, conceptual simplicity, and a verified formal foundation. It establishes a new paradigm for both the formal study of type classes and their principled compiler implementation.
📝 Abstract
We present a new, uniform semantics for Haskell-style overloading. We realize our approach in a new core language, System F$_mathrm{D}$, whose metatheory we mechanize in the Lean4 interactive theorem prover. System F$_mathrm{D}$ is distinguished by its open data types and open functions, each given by a collection of instances rather than by a single definition. We show that System F$_mathrm{D}$ can encode advanced features of Haskell's of type class systems, more expressively than current semantics of these features, and without assuming additional type equality axioms.