Search code examples
scalaz-stream

In scalaz stream, how can i turn a Process[Task,Seq<B>] into a Process1[Task,B]


I have a Process[Task,A]. A contains a Seq of Bs

case class A(elems:Seq[B])

I would like to transform the Process[Task,A] into a Process[Task,B]

def streamOfAs:Process[Task,A] = ???

streamOfBs1:Process[Task,Member] = streamOfAs.flatMap(Process.emit(_.elems)) //Compiler error
streamOfBs2:Process[Task,Member] = streamOfAs pipe process1.lift((a:A) => a.elems) //yields Process[Task,Seq[B]]

are there any buildtin functions to achieve this?


Solution

  • If I understand correctly the case class A is essentially function A => Seq[B]

    then solution would be perhaps

    val sourceB: Process[Task,B] = sourceA.flatMap(emitAll(_.elems))