Total type classes
File(s) 3759164.3759349.pdf (737.75 KB)
Published version
Author(s)
Weingart, Robert
Wu, Nicolas
Type
Conference Paper
Abstract
In Haskell, type classes can act like functions from types to terms. However, unlike for functions, there is no way for the programmer to ask the compiler to verify that classes pattern-match exhaustively on their arguments, and their usage must always be marked by a constraint even when they are exhaustive.
This paper introduces the notion of total type classes and, more generally, total constraints, which allow the programmer to describe a set of instances whose existence can be verified by inspecting the instance declarations of the class, instead of on a case-by-case basis when a specific instance is demanded. To achieve this functionality, our implementation records the missing constraints during typechecking and then modifies the typechecked program, rewriting it as though the programmer had included the constraints.
This paper introduces the notion of total type classes and, more generally, total constraints, which allow the programmer to describe a set of instances whose existence can be verified by inspecting the instance declarations of the class, instead of on a case-by-case basis when a specific instance is demanded. To achieve this functionality, our implementation records the missing constraints during typechecking and then modifies the typechecked program, rewriting it as though the programmer had included the constraints.
Date Issued
2025-10-09
Date Acceptance
2025-10-07
Citation
Haskell '25: Proceedings of the 18th ACM SIGPLAN International Haskell Symposium, 2025, pp.53-66
ISBN
979-8-4007-2147-2
Publisher
Association for Computing Machinery
Start Page
53
End Page
66
Journal / Book Title
Haskell '25: Proceedings of the 18th ACM SIGPLAN International Haskell Symposium
Copyright Statement
Copyright © 2025 Owner/Author. This work is licensed under Creative Commons Attribution International 4.0.
License URL
Identifier
10.1145/3759164.3759349
Source
18th ACM SIGPLAN International Haskell Symposium
Subjects
CCS Concepts: • Software and its engineering → Functional languages
Source code generation
Preprocessors type classes, pattern matching, constraints
Publication Status
Published
Start Date
2025-10-12
Finish Date
2025-10-18
Coverage Spatial
Singapore
