Skip to content

Instantly share code, notes, and snippets.

@nuttycom
Forked from jdegoes/BindSemigroup.scala
Created December 18, 2011 23:12

Revisions

  1. nuttycom revised this gist Dec 18, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions BindSemigroup.scala
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,3 @@
    implicit def BindSemigroup[M[_], A](implicit bind: Bind[M]): Semigroup[M[A]] = new Semigroup[M[A]] {
    def append(v1: M[A], v2: => M[A]): M[A] = bind.bind(v1)((a: A) => v2)
    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, _)))
    }
  2. @jdegoes jdegoes created this gist Dec 18, 2011.
    3 changes: 3 additions & 0 deletions BindSemigroup.scala
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    implicit def BindSemigroup[M[_], A](implicit bind: Bind[M]): Semigroup[M[A]] = new Semigroup[M[A]] {
    def append(v1: M[A], v2: => M[A]): M[A] = bind.bind(v1)((a: A) => v2)
    }