conduit-extra-0.1.1: Experimental helper functions for conduit.

Safe HaskellNone

Data.Conduit.Extra.ZipSink

Synopsis

Documentation

newtype ZipSink i m r Source

A wrapper for defining an Applicative instance for Sinks which allows to combine sinks together, generalizing zipSinks. A combined sink distributes the input to all its participants and when all finish, produces the result. This allows to define functions like

 broadcast :: (Monad m)
           => [Sink i m r] -> Sink i m [r]
 broadcast = getZipSink . sequenceA . fmap ZipSink

Note that the standard Applicative instance for conduits works differently. It feeds one sink with input until it finishes, then switches to another, etc., and at the end combines their results.

Constructors

ZipSink 

Fields

getZipSink :: Sink i m r
 

Instances

Monad m => Functor (ZipSink i m) 
Monad m => Applicative (ZipSink i m) 

broadcast :: (Traversable f, Monad m) => f (Sink i m r) -> Sink i m (f r)Source