Sanely-automatic derivation - or how type class derivation works and why everyone else is doing it wrong

In Scala, we generate quite a lot of code. A lot of that involves the compiler generating so-called type class instances. This mechanism is quite widespread, yet, very few people actually understand it. As a result, we, the community, settled for suboptimal practices, resulting in suboptimal performance and user experience.