Scale By The Bay 2020: Shameera Rathnayaka, Materialize Typeclasses with Magnolia
ai.bythebay.io Nov 2025, Oakland, full-stack AI conference Magnolia is the modern way of materializing Typeclasses for any datatypes composed with product(case class) and co-product(trait). Magnolia is a simpler yet powerful and performant library. Highly functional programming libraries like cats and algebirds heavily depend on type classes. Most of the time, developing a scala library requires to write library-specific Typeclasses, and library users need to implement their domain-specific instances of these Typeclasses. This step could be automated with Magnolia. In Spotify, we use Magnolia to compile-time Typeclass generations for many storage types(Avro, Protobuf, Bigquery, etc.) to Scala case classes and use with Scio. This reduces a lot of boilerplate code, which otherwise users have to handcraft. This code is open source and available under spotify/magnolify github repository. Let's get our hand dirty and implement a case class diffing library that outputs the difference of any given case classes. Here we will use Magnolia to derive the type classes for any given datatype(product or coproduct). Let's talk about the limitations of the Magnolia library and how to work around some of it. Shameera Rathnayaka Spotify Senior Engineer Websitehttps://twitter.com/syodage I am a Senior Data Infrastructure Engineer in Spotify and a member of the Scio(Idiomatic Scala wrapper to Apache Beam) development team. Open source enthusiastic, a contributor to many open-source projects, and an Apache PMC member. A couple of years ago, I started to work with Scala and pretty obsessed wit…