Unified type checking for type classes and type families

Haksell has a rich type system with various complementary, interacting and overlapping features. In particular we think of the established type classes, with several extensions: multiple parameters, functional dependencies, . . . In a recent proposal, a new feature is added to the Haskell language: type-level functions, or type families in GHC. This multitude of type-level features is a blessing for programmers. A well-chosen combination of features allows the accurate expression of many problem domain semantics. However, the plethora of features is also a nightmare for Haskell compiler writers, who have to implement and maintain all these features. For instance, GHC’s core type checking modules for type classes and type families comprise approximately 3,1 kloC and 1,2 kloc, which is understood by very few people. Currently, no other Haskell system has managed to provide the same type class functionality as GHC. The contributions of this work aim at recuding the implementation complexity of two Haskell type system features, type classes and type families: