alexelcu,
@alexelcu@social.alexn.org avatar

Scala has Type Classes as first-class citizens.

In a narrow sense, that's because instances get passed around as values. By comparison, Haskell devs talk about sometimes preferring “dictionary passing style” instead of typeclasses. In Scala, it's the same thing.

Ofc, Scala can't really force global uniqueness, AKA “coherence”, which is important for making data structures reusable & ensuring the correctness of operations on that data…

1/2

#Scala #TypeClasses

alexelcu,
@alexelcu@social.alexn.org avatar

But the coherence you get (in lexical scope, or due to global visibility rules) is good enough.

Scala 3 also has type classes as first-class in a broader sense.

We now have better syntax, e.g., for defining extension methods meant for type classes, or for auto-derivation. And defining auto-derivation logic doesn't involve macros, most of the time.

2/2

#Scala #Scala3

  • All
  • Subscribed
  • Moderated
  • Favorites
  • programming
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines