You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the answer for Monoid[Option[A]], by just using 'orElse' is too simplified, see below def optionMonoid[A]: Monoid[Option[A]] = new Monoid[Option[A]] { def op(x: Option[A], y: Option[A]) = x orElse y val zero = None }
I think the answer for Monoid[Option[A]], by just using 'orElse' is too simplified, see below
def optionMonoid[A]: Monoid[Option[A]] = new Monoid[Option[A]] { def op(x: Option[A], y: Option[A]) = x orElse y val zero = None }
https://stackoverflow.com/a/43517616/4582240
https://typelevel.org/cats/typeclasses/monoid.html
has better implementation. i.e. it goes deeper into type A, to combine them. and requires A has a semiGroup instance, i.e. A has combine operation.
(implicit sgA: Semigroup[A])
but my question is when would you use the 'orElse' approach implelmentation? Is it due to what kind of problem you are trying to solve?
The text was updated successfully, but these errors were encountered: