Cats: UnorderedFoldable#isEmpty default implementation is incorrect

Created on 26 Oct 2018  路  3Comments  路  Source: typelevel/cats

The default implementation of UnorderedFoldable#isEmpty (and thus nonEmpty) seems to be incorrect.

val inst: cats.UnorderedFoldable[Set] = new cats.UnorderedFoldable[Set] {
  def unorderedFoldMap[A, B](s: Set[A])(f: A => B)(implicit B: cats.kernel.CommutativeMonoid[B]): B =
    cats.instances.set.catsStdInstancesForSet.unorderedFoldMap(s)(f)
}

inst.isEmpty(Set.empty) // returns false
bug help wanted low-hanging fruit

Most helpful comment

I can help with this if that's ok

All 3 comments

Ouch. It looks like the implementations of isEmpty and nonEmpty are switched around. The fix is easy, but we should also add some tests for this. This is a super busy week for me. Does anybody want to give it a go?

I can help with this if that's ok

closed by #2586

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Atry picture Atry  路  5Comments

durban picture durban  路  4Comments

SimY4 picture SimY4  路  4Comments

tg44 picture tg44  路  4Comments

kailuowang picture kailuowang  路  5Comments