Skip to content

Instantly share code, notes, and snippets.

@kolov
Last active March 7, 2018 13:47
Show Gist options
  • Save kolov/86ca7a1bd81fd2b3cb8c3d6e9f1eb364 to your computer and use it in GitHub Desktop.
Save kolov/86ca7a1bd81fd2b3cb8c3d6e9f1eb364 to your computer and use it in GitHub Desktop.
trait Semigroup[A] {
def combine(x: A, y: A): A
}
trait Monoid[A] extends Semigroup[A] {
def zero: A
}
// Laws:
//Associativity
append(a1, append(a2, a3)) == append(append(a1, a2), a3)
//Identity
append(a, zero) == a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment