How to convert scalaz-stream Process[F, Option[T]] to Process[F, T]?

51 Views Asked by At

I have a scalaz-stream process:

val src = Process.repeatEval(Task(in.take())) : Process[Task, Option[T]]

How do I get rid of Option?

So far I've used collect but it doesn't feel elegant:

src.collect { case Some(x) => x } : Process[Task, T]

Is there a better way?

1

There are 1 best solutions below

0
Gary Coady On

Your solution is correct, but the implementation is already present in scalaz-stream (<= 0.8), in process1.stripNone:

src.pipe(process1.stripNone)

or

src |> process1.stripNone

Many other transformations (possibly stateful) are defined in process1, so it's worth looking through the file for possibly useful transformations.