Unable to use the |+| syntax as presented in 2.5.4
Closed this issue · 2 comments
nsadeh commented
I got
import cats.Monoid
import cats.syntax.semigroup._
def add[A](items: List[A])(implicit m: Monoid[A]): A = items.foldLeft(m.empty)(_ |+| _)
This gives me value |+| is not a member of type parameter A
. Same error with context bound syntax.
What does work is
def add[A](items: List[A])(implicit m: Monoid[A]): A = items.foldLeft(m.empty)(m.combine _)
Is this an error in the book or is there a compiler arg I am missing?
noelwelsh commented
That code looks correct to me. You might try import cats.implicits._
instead of the imports you list, just to make sure nothing is missing. If you can upload a complete project I'll can take a look when time allows.
noelwelsh commented
I haven't heard back from you so I'm closing this.