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

Fix ReducibleLaws causing stack overflow by calling Eval.now early #3565

Merged
merged 1 commit into from
Aug 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions laws/src/main/scala/cats/laws/ReducibleLaws.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ trait ReducibleLaws[F[_]] extends FoldableLaws[F] {
fa.reduceRightTo(f)((a, eb) => eb.map(f(a) |+| _)).map(Option(_)).value

def reduceRightConsistentWithReduceRightOption[A](fa: F[A], f: (A, A) => A): IsEq[Option[A]] =
fa.reduceRight((a1, e2) => Now(f(a1, e2.value))).map(Option(_)).value <->
fa.reduceRightOption((a1, e2) => Now(f(a1, e2.value))).value
fa.reduceRight((a1, e2) => e2.map(f(a1, _))).map(Option(_)).value <->
fa.reduceRightOption((a1, e2) => e2.map(f(a1, _))).value

def reduceReduceLeftConsistent[B](fa: F[B])(implicit B: Semigroup[B]): IsEq[B] =
fa.reduce <-> fa.reduceLeft(B.combine)
Expand Down