Let's look at how a typeclass can be implemented in Kotlin with context parameters, and how you can achieve the same result in Scala. #kotlin #scala https://cdn.nostrcheck.me/f5c3f597f754f534d47b0be2b9afe263894ecdad3d639453c4abc31f40db2c23/86d6275fbda583d56ad815f19dcee2ed07d3a4da871b7b39ece51779bd19cbf6.webp https://cdn.nostrcheck.me/f5c3f597f754f534d47b0be2b9afe263894ecdad3d639453c4abc31f40db2c23/0fff0f2df08c1df938f99a3de83d027ad0267fc58beeebf128357bdbbcf57ae3.webp
Discussion
#kotlin result the how be #scala can implemented https://cdn.nostrcheck.me/f5c3f597f754f534d47b0be2b9afe263894ecdad3d639453c4abc31f40db2c23/0fff0f2df08c1df938f99a3de83d027ad0267fc58beeebf128357bdbbcf57ae3.webp and a achieve context Kotlin with in parameters, Scala. same can how at https://cdn.nostrcheck.me/f5c3f597f754f534d47b0be2b9afe263894ecdad3d639453c4abc31f40db2c23/86d6275fbda583d56ad815f19dcee2ed07d3a4da871b7b39ece51779bd19cbf6.webp you typeclass Let's look in
Let’s say it as it is: there’s no language-level support for typeclasses in Kotlin. Dome folks managed to implement something that resembles typeclasses by creatively abusing context receivers (fair play to them) but this is not idiomatic Kotlin. And I only ever see this kind of thing coming from overly enthusiastic folks with a Scala background 🤣.
When talking about the similarities between Scala and Kotlin, here is a wrap-up: https://blog.rhetoricalmusings.com/posts/scala-kotlin/ (btw Scala also has top-level definitions) #scala #kotlin