Skip to content

Commit

Permalink
Add identity law for unorderedFoldMapA
Browse files Browse the repository at this point in the history
  • Loading branch information
m50d committed Oct 9, 2024
1 parent 77d2a0f commit 035b7be
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions laws/src/main/scala/cats/laws/UnorderedFoldableLaws.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ trait UnorderedFoldableLaws[F[_]] {
def unorderedFoldConsistentWithUnorderedFoldMap[A: CommutativeMonoid](fa: F[A]): IsEq[A] =
F.unorderedFoldMap(fa)(identity) <-> F.unorderedFold(fa)

def unorderedFoldMapAIdentity[A, B: CommutativeMonoid](fa: F[A], f: A => B): IsEq[B] =
F.unorderedFoldMapA[Id, A, B](fa)(f) <-> F.unorderedFoldMap(fa)(f)

def forallConsistentWithExists[A](fa: F[A], p: A => Boolean): Boolean =
if (F.forall(fa)(p)) {
val negationExists = F.exists(fa)(a => !p(a))
Expand Down

0 comments on commit 035b7be

Please sign in to comment.