sequence package:streamly
sequence = mapM id
Replace the elements of a stream of monadic actions with the outputs
of those actions.
>>> drain $ Stream.sequence $ Stream.fromList [putStr "a", putStr "b", putStrLn "c"]
abc
>>> :{
drain $ Stream.replicateM 3 (return $ threadDelay 1000000 >> print 1)
& (fromSerial . Stream.sequence)
:}
1
1
1
>>> :{
drain $ Stream.replicateM 3 (return $ threadDelay 1000000 >> print 1)
& (fromAsync . Stream.sequence)
:}
1
1
1
Concurrent (do not use with fromParallel on infinite
streams)
Definition:
>>> parSequence modifier = Stream.parMapM modifier id
Useful idioms:
>>> parFromListM = Stream.parSequence id . Stream.fromList
>>> parFromFoldableM = Stream.parSequence id . StreamK.toStream . StreamK.fromFoldable
Apply a stream of folds to an input stream and emit the results in the
output stream.
Unimplemented
Returns
True if all the elements of the first stream occur, in
order, in the second stream. The elements do not have to occur
consecutively. A stream is a subsequence of itself.
>>> Stream.isSubsequenceOf (Stream.fromList "hlo") (Stream.fromList "hello" :: SerialT IO Char)
True
Apply a stream of parsers to an input stream and emit the results in
the output stream.
Unimplemented