unzip package:io-streams
Takes apart a stream of pairs, producing a pair of input streams.
Reading from either of the produced streams will cause a pair of
values to be pulled from the original stream if necessary. Note that
reading n values from one of the returned streams will cause
n values to be buffered at the other stream.
Access to the original stream is thread safe, i.e. guarded by a lock.
Given two
OutputStreams, returns a new stream that "unzips" the
tuples being written, writing the two elements to the corresponding
given streams.
You can use this together with
contramap (\ x -> (x,
x)) to "fork" a stream into two.
Since: 1.5.2.0