Skip to content

Instantly share code, notes, and snippets.

@nuttycom
Forked from jdegoes/BindSemigroup.scala
Created December 18, 2011 23:12
Show Gist options
  • Save nuttycom/1494778 to your computer and use it in GitHub Desktop.
Save nuttycom/1494778 to your computer and use it in GitHub Desktop.
BindSemigroup
implicit def BindSemigroup[M[_], A](implicit bind: Bind[M], s: Semigroup[A]): Semigroup[M[A]] = new Semigroup[M[A]] {
def append(v1: M[A], v2: => M[A]): M[A] = bind.bind(v1)((a: A) => v2.map(s.append(a, _)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment