I have a result consisting of a list of vectors in a scalaz clause, and I want to be able to examine and filter out elements on the right side.
simplified example:
import scalaz._ import Scalaz._ type TL = Throwable \/ List[Vector[Int]] val goodTL: TL = \/-(List(Vector(1,2,3),Vector(), Vector(2,3,4)))
If I want to remove an empty element, as well as any values! = 2 from the filled elements, I can do the following:
for { v <- goodTL f = v.flatten } yield for { i <- f if i != 2 } yield i
giving scalaz.\/[Nothing,List[Int]] = \/-(List(1, 3, 3, 4)) what I want, but I would like to know if there is a less complicated way to achieve this.
source share