https://kotlinlang.org logo
Title
a

addamsson

04/18/2023, 10:18 AM
@simon.vergauwen can typeclasses be implemented with the new
context()
thingy?
s

simon.vergauwen

04/18/2023, 10:25 AM
Yes, but not all functionality for which they’re used in Haskell and Scala. I.e generic derivation requires compile type injection and higher kinded types are still needed to abstract over containers. But many other useful patterns that typeclasses are used for can be replaced by context receivers. To work around HKT limitation we’ve started using (monadic) DSLs and that eliminates the need for HKTs in Kotlin IMO. Generic derivation is a bit niche, and other solutions are typically used. KSP or plugins.
a

addamsson

04/18/2023, 10:45 AM
damn
s

simon.vergauwen

04/18/2023, 10:46 AM
Perhaps to clarify. TL;DR On paper no, in practice yes 😄
a

addamsson

04/18/2023, 10:47 AM
oh
then nice 👍
i've moved to typescript a while ago and started to use fp-ts so I learned the ropes...
but now i'll work on a kotlin project so I thought I'll take a look at what changed