cats icon indicating copy to clipboard operation
cats copied to clipboard

Add traverseCollect to TraverseFilter typeclass

Open LukaJCB opened this issue 2 years ago • 2 comments

Analogous to the collect method on FunctorFilter we can define a traverseCollect method derived from traverseFilter using a PartialFunction like this:

 def traverseCollect[F[_]: TraverseFilter, G[_]: Applicative, A, B](fa: F[A], f: PartialFunction[A, G[B]]): G[F[B]] =
    fa.traverseFilter(a => f.lift(a).sequence)

LukaJCB avatar Jul 28 '22 20:07 LukaJCB

Can I help with this? I'm looking for my first contribution to Cats.

emilhotkowski avatar Jul 29 '22 19:07 emilhotkowski

@emilhotkowski indeed, that would be great!

armanbilge avatar Jul 29 '22 19:07 armanbilge