Updated Documentation for Typeclass Derivation
Today in Dotty News: Miles has just submitted a PR with rewritten docs for the derived
and derives
features.
It’s particularly interesting for those of us who enjoy Power Scala, and like to know how to do the crazy and cool stuff. These features bring a lot of the functionality that was previously only available via macros and/or Shapeless within reach of (hardcore) application code. They make it possible to make typeclasses automatically deriveable with a plausible amount of comprehensible code (even if you don’t use higher-level tools such as Shapeless), and make it dead-easy to create instances for those typeclasses on well-behaved types such as case classes.
One of the more exciting aspects of Dotty and Scala 3 is that they recognize the centrality of typeclasses in modern, idiomatic Scala, and the team is working to make typeclasses easier and clearer to use. This derivation system is an important component of that evolution. Worth checking out if you like the chewier aspects of Scala.
Usual caveat: this is just a PR. That said, I think the feature is a near-lock for inclusion in Scala 3 (lots of us desperately want it), and things seem to be stabilizing, so this documentation probably isn’t too far from the final form, I suspect.