I've been playing with Scalaz-Streams (0.7.3 and 0.8) and noticed this curious behaviour which I don't understand. As an experiment I am creating multiple processes and using the output of one process as the input for the next process. In doing so, I seem to blow the stack. Initially I thought it was because I'm appending the stream with a recursive call to the function that creates the stream. But I discovered that replacing the flatMap
in the first example below with map/mergeN
and it stopped blowing the stack. Curiously though using map/mergeN
was waaaaaaaay slower than using flatMap
. So, why is flatMap
blowing the stack and why is mergeN
so slow?
import scalaz.concurrent.Task
import scalaz.stream._
object Main extends App {
def infiniteInts(streamOfInts: Process[Task, Int]): Process[Task, Int] = {