First I have a case class defined as (this is part of a library):
final case class Abstraction[A](
result: Either[AbError, A],
status: Int,
info: Map[String, String]
)
I want to use it as a primary component for fold in order to go from List[IO[Abstraction[List[A]]]] to IO[Abstraction[List[A]]].
As I read I thought of making it an instance of Monoid to define the behavior to merge the final result.
My proposition is as follows but I know it has mistakes as I'm not grasping it very well.
implicit val instanceabstaction : Monoid[Abstraction[A]] = new Monoid[Abstraction[A]] = {
def empty: Abstraction[A] = Abstraction(Either.empty[AbError, A] , 0 , Map.empty[String, String])
def combine(x: Abstraction[A], y: Abstraction[A]): Int = x ++ y
}
If there is any other way to achieve this, I'm open to propositions