Type classes in Scala 3
Type classes are a powerful tool in functional programming to enable ad-hoc polymorphism without using object orientated programming based constructs like sub typing. In this talk we look at how to create type classes using Scala 3 constructs such as ‘Givens’ and ‘Extension’ methods.
Outline/Structure of the Talk
- Recap of classical Polymorphism (subtyping) - 3 minutes
- Concept of Ad-Hoc polymorphism in Scala via typeclasses - 5 minutes
- Typeclasses before Scala 3 i.e implicits - 5 minutes
- Implicit hell problem - 2 minutes
- Scala 3 extension methods - 10 minutes
- Scala 3 given constructs - 10 minutes
- Using extension methods and given constructs to create type classes - 5 minutes
- Questions - 5 minutes
Learning Outcome
- Audience will clearly understand the concept Ad-Hoc polymorphism in Scala
- Audience will understand on how we implement ad-hoc polymorphism in Scala 3.
- Audience will appreciate improvements in Scala 3 over Scala 2.
Target Audience
Scala developers looking to learn Scala 3 aka Dotty features
Prerequisites for Attendees
- Concept of Polymorphism
- Basic scala knowledge
Video
Links
- Ayush Mittal at #ScalaUA - Effectful* programming in Scala - https://www.youtube.com/watch?v=kTsAMzar5Qc&t=101s
- Effectful programming in Scala by Ayush Mitta - https://www.youtube.com/watch?v=Oc5W3FuK-Hs&t=1899s
- A TRACE TO REMEMBER: COMPOSITIONAL TRACING - Ayush Mittal | Scalar 2020 - https://www.youtube.com/watch?v=c71nI2CCmkQ&t=939s
- ING Scala Meetup : Working with Dotty - https://www.youtube.com/watch?v=qqqfImDtduE&t=9s
Public Feedback