Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pointwise Semigroup
trait Semigroup[A] {
def op(a1: A, a2: A): A
}
object Semigroup {
def PointwiseSemigroup[A, B](implicit S: Semigroup[B]): Semigroup[A => B] =
new Semigroup[A => B] {
def op(b1: A => B, b2: A => B) =
a => S.op(b1(a), b2(a))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment