I have a question about the streaming package.
Let's say I have str :: Stream (Of String) IO ()I want to putStrLn each element and then print the length of str, so I could do this:
import Streaming
import qualified Streaming.Prelude as SP
doit :: Stream (Of String) IO () -> IO ()
doit str =
do
SP.mapM_ putStrLn str
SP.length_ str >>= print
However, will this result in doing 2 passes over str so that the memory requirement is not constant? If so, is there a simple way to combine the two actions so that only pass is needed? I could probably use a counter in a StateT but that's not really simple. More generally, are there techniques for combining folds like how one would with the foldl package?