You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As far as I can tell, this syntax isn't described anywhere in the book, and it's not exactly intuitive.
So in my opinion, it would be nice if this syntax (or its alternatives for older Scala versions) was explained anywhere in the Scala 3 book. Maybe it doesn't have to be in the type class section because it is about bounds more generally, although it may also be worth pointing out how the as syntax specifically is useful for disambiguating between different type classes that have some identically named methods (cf. e.g. Rust's book which has an entire section on how to handle this case).
The text was updated successfully, but these errors were encountered:
smheidrich
changed the title
Scala 3 book should describe how to have more than one typeclass as a bound
Scala 3 book should describe how to have more than one bound (e.g. when using typeclasses)
Mar 24, 2025
smheidrich
changed the title
Scala 3 book should describe how to have more than one bound (e.g. when using typeclasses)
Scala 3 book should describe aggregate bounds (e.g. when using typeclasses)
Mar 24, 2025
smheidrich
changed the title
Scala 3 book should describe aggregate bounds (e.g. when using typeclasses)
Scala 3 book should describe aggregate bounds (e.g. for typeclasses)
Mar 24, 2025
The Scala 3 book's section on writing methods that use type classes only shows how to specify a single type class as a parameter's bound.
How to specify multiple bounds is described in the Aggregate Context Bounds section of the reference:
As far as I can tell, this syntax isn't described anywhere in the book, and it's not exactly intuitive.
So in my opinion, it would be nice if this syntax (or its alternatives for older Scala versions) was explained anywhere in the Scala 3 book. Maybe it doesn't have to be in the type class section because it is about bounds more generally, although it may also be worth pointing out how the
as
syntax specifically is useful for disambiguating between different type classes that have some identically named methods (cf. e.g. Rust's book which has an entire section on how to handle this case).The text was updated successfully, but these errors were encountered: