Some Name
Some Name

Reputation: 9521

Derive semigroup instance for F[A]

It seems trivial to implement it on our own:

implicit def s[F[_]: Monad, A: Semigroup]: Semigroup[F[A]] = 
  Semigroup.instance((fa, fb) => for {
    fa <- fa
    fb <- fb
  } yield fa |+| fb)

But is it possible to derive it automatically? Kittens seems to work with case classes (at least I tried it for that case and it didn't work).

Upvotes: 0

Views: 81

Answers (0)

Related Questions