The Limitations of Type Classes as Subtyped Implicits (Short Paper)
Type classes enable a powerful form of ad-hoc polymorphism which provide solutions to many programming design problems. Inspired by this, Scala programmers have striven to emulate them in the design of libraries like Scalaz and Cats.
The natural encoding of type classes combines subtyping and implicits, both central features of Scala. However, this encoding has limitations. If the type class hierarchy branches, seemingly valid programs can hit implicit resolution failures. These failures must then be solved by explicitly passing the implicit arguments which is cumbersome and negates the advantages of type classes.
In this paper we describe instances of this problem and show that they are not merely theoretical but often arise in practice. We also discuss and compare the space of solutions to this problem in Scala today and in the future.
Sun 22 Oct
|10:30 - 11:00|
Abel NietoUniversity of WaterlooDOI Pre-print File Attached
|11:00 - 11:30|
Adelbert ChangUnaffiliatedDOI Pre-print
|11:30 - 12:00|
|DOI Media Attached|