Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scalaz7 - Monoid instances for TupleX incorrect #34

Closed
derekjw opened this issue Jul 27, 2011 · 1 comment
Closed

Scalaz7 - Monoid instances for TupleX incorrect #34

derekjw opened this issue Jul 27, 2011 · 1 comment

Comments

@derekjw
Copy link
Contributor

derekjw commented Jul 27, 2011

The current Monoid instances for Tuples cause stack overflow.

A working implementation for Tuple2:

implicit def Tuple2Monoid[A, B](implicit ma: Monoid[A], mb: Monoid[B]): Monoid[(A, B)] = {
  implicit val sa = ma.semigroup
  implicit val za = ma.zero
  implicit val sb = mb.semigroup
  implicit val zb = mb.zero
  monoid[(A, B)]
}
@nkpart
Copy link
Contributor

nkpart commented Aug 27, 2012

Seems okay now:

scala> import scalaz.std.tuple._
scala> import scalaz.std.anyVal._
scala> import scalaz.syntax.monoid._

scala> mzero[Int]
res1: Int = 0

scala> mzero[(Int, Int)]
res2: (Int, Int) = (0,0)

scala>

@nkpart nkpart closed this as completed Aug 27, 2012
Atry added a commit to Atry/scalaz that referenced this issue Jul 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants