Skip to content

Commit

Permalink
update laws
Browse files Browse the repository at this point in the history
  • Loading branch information
satorg committed Nov 28, 2024
1 parent b05978e commit 40548ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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 @@ -54,10 +54,10 @@ trait ReducibleLaws[F[_]] extends FoldableLaws[F] {
fa.reduce <-> fa.reduceLeft(B.combine)

def traverseConsistent[G[_]: Applicative, A, B](fa: F[A], f: A => G[B]): IsEq[G[Unit]] =
fa.nonEmptyTraverse_(f) <-> fa.traverse_(f)
fa.nonEmptyTraverseVoid(f) <-> fa.traverseVoid(f)

def sequenceConsistent[G[_]: Applicative, A](fa: F[G[A]]): IsEq[G[Unit]] =
fa.nonEmptySequence_ <-> fa.sequence_
fa.nonEmptySequenceVoid <-> fa.sequenceVoid

def sizeConsistent[A](fa: F[A]): IsEq[Long] =
fa.size <-> fa.reduceMap(_ => 1L)
Expand Down
4 changes: 2 additions & 2 deletions laws/src/main/scala/cats/laws/discipline/ReducibleTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ trait ReducibleTests[F[_]] extends FoldableTests[F] {
forAll(laws.reduceRightConsistentWithReduceRightOption[A] _),
"reduce consistent with reduceLeft" ->
forAll(laws.reduceReduceLeftConsistent[B] _),
"nonEmptyTraverse_ consistent with traverse_" -> forAll(laws.traverseConsistent[G, A, B] _),
"nonEmptySequence_ consistent with sequence_" -> forAll(laws.sequenceConsistent[G, A] _),
"nonEmptyTraverseVoid consistent with traverseVoid" -> forAll(laws.traverseConsistent[G, A, B] _),
"nonEmptySequenceVoid consistent with sequenceVoid" -> forAll(laws.sequenceConsistent[G, A] _),
"size consistent with reduceMap" -> forAll(laws.sizeConsistent[A] _)
)
}
Expand Down

0 comments on commit 40548ac

Please sign in to comment.