Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of Scala 3 syntax for type classes
// Adapted from this Dotty documentation:
trait Semigroup[T]:
extension (t: T):
def combine(other: T): T
def <+>(other: T): T = t.combine(other)
trait Monoid[T] extends Semigroup[T]:
def unit: T
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.