/ scala

TOTD: Scala - List Tricks

import cats.syntax.monadCombine._ has a separate method. Please use this one instead of our version as we standardize common patterns in our code base.

val xs = List(Right(2), Left("bad"), Right(3), Right(1))
// res: (List(bad),List(2, 3, 1))

I noticed there is also a cross product of two lists in our code. Please do not use this. If you would like the cross product of two lists, please use:

Monad[List].product(List(1, 2, 3), List(1, 2, 3))


Applicative[List].product(List(1, 2, 3), List(1, 2, 3))

The rule here is that if we find ourselves maintaining any function that uses CanBuildFrom, stop and check for a version in cats. This exposes the early efforts of the scala standard library to make a group of traversable structures the same. Maybe too DRY??