Hi everyone,
I suggest to add such thing to Monoid object. Basically it gives you a monoid for a tagged type, given a monoid for this type. I found it quite useful,
and if you think that it makes sense, I can make PR.
implicit def monoidOfTagged[T, A](implicit M0: Monoid[A]): Monoid[A @@ T] = new Monoid[@@[A, T]] {
override def zero: @@[A, T] = Tag.of[T](M0.zero)
override def append(f1: @@[A, T], f2: ⇒ @@[A, T]): @@[A, T] =
Tag.of[T](M0.append(Tag.unwrap(f1), Tag.unwrap(f2)))
}
And one more suggestion.
You can always take out function from Monad - if it returns the value inside this Monad:
def ???[A, B, F[_]: Monad](f: F[A ⇒ F[B]]): A ⇒ F[B] = a ⇒ {
Monad[F].bind(f)(ff ⇒ ff(a))
}
It just feels a bit weird to have such high level function laying in the Utils. I did not find such thing in scalaZ, so may be it makes sense to add it as well.
Thanks for a great library!
Cheers,
Gleb