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

Safe HaskellNone

Data.Conduit.Extra.ZipConduit

Synopsis

Documentation

newtype ZipConduit i o m r

Provides an alternative Applicative instance for ConduitM. In this instance, every incoming value is provided to all ConduitMs, and output is coalesced together. Leftovers from individual ConduitMs will be used within that component, and then discarded at the end of their computation. Output and finalizers will both be handled in a left-biased manner.

As an example, take the following program:

 main :: IO ()
 main = do
     let src = mapM_ yield [1..3 :: Int]
         conduit1 = CL.map (+1)
         conduit2 = CL.concatMap (replicate 2)
         conduit = getZipConduit $ ZipConduit conduit1 <* ZipConduit conduit2
         sink = CL.mapM_ print
     src $$ conduit =$ sink

It will produce the output: 2, 1, 1, 3, 2, 2, 4, 3, 3

Since 1.0.17

Constructors

ZipConduit 

Fields

getZipConduit :: ConduitM i o m r
 

Instances

Monad m => Functor (ZipConduit i o m) 
Monad m => Applicative (ZipConduit i o m) 

sequenceConduits :: (Traversable f, Monad m) => f (ConduitM i o m r) -> ConduitM i o m (f r)

Provide identical input to all of the Conduits and combine their outputs into a single stream.

Implemented on top of ZipConduit, see that data type for more details.

Since 1.0.17