On the State of Coherence in the Land of Type Classes
Dimi Racordon (EPFL, Switzerland), Eugene Flesselle (EPFL,, Switzerland), Cao Nguyen Pham (EPFL, Switzerland)

TL;DR
This paper examines how different programming languages like Swift, Rust, Scala, and Haskell handle coherence issues in type classes, highlighting their similarities and differences in implicit resolution and instance uniqueness.
Contribution
It provides a comparative analysis of coherence strategies in Swift, Rust, Scala, and Haskell, clarifying the design space and commonalities among these languages.
Findings
Swift, Rust, and Scala share core coherence principles with Haskell.
Different languages balance flexibility and safety in implicit resolution.
The paper clarifies the design space for type class coherence in mainstream languages.
Abstract
Type classes are a popular tool for implementing generic algorithms and data structures without loss of efficiency, bridging the gap between parametric and ad-hoc polymorphism. Since their initial development in Haskell, they now feature prominently in numerous other industry-ready programming languages, notably including Swift, Rust, and Scala. The success of type classes hinges in large part on the compilers' ability to infer arguments to implicit parameters by means of a type-directed resolution. This technique, sometimes dubbed **implicit programming**, lets users elide information that the language implementation can deduce from the context, such as the implementation of a particular type class. One drawback of implicit programming is that a type-directed resolution may yield ambiguous results, thereby threatening coherence, the property that valid programs have exactly one…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
