-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Streaming data processing library. -- -- conduit is a solution to the streaming data problem, allowing -- for production, transformation, and consumption of streams of data in -- constant memory. It is an alternative to lazy I/O which guarantees -- deterministic resource handling. -- -- For more information about conduit in general, and how this package in -- particular fits into the ecosystem, see the conduit homepage. -- -- Hackage documentation generation is not reliable. For up to date -- documentation, please see: -- http://www.stackage.org/package/conduit. @package conduit @version 1.2.13 module Data.Conduit.Internal.Fusion -- | This is the same as stream fusion's Step. Constructors are renamed to -- avoid confusion with conduit names. data Step s o r Emit :: s -> o -> Step s o r Skip :: s -> Step s o r Stop :: r -> Step s o r data Stream m o r Stream :: (s -> m (Step s o r)) -> (m s) -> Stream m o r data ConduitWithStream i o m r type StreamConduitM i o m r = Stream m i () -> Stream m o r type StreamConduit i m o = StreamConduitM i o m () type StreamSource m o = StreamConduitM () o m () type StreamProducer m o = forall i. StreamConduitM i o m () type StreamSink i m r = StreamConduitM i Void m r type StreamConsumer i m r = forall o. StreamConduitM i o m r streamConduit :: ConduitM i o m r -> (Stream m i () -> Stream m o r) -> ConduitWithStream i o m r streamSource :: Monad m => Stream m o () -> ConduitWithStream i o m () streamSourcePure :: Monad m => Stream Identity o () -> ConduitWithStream i o m () unstream :: ConduitWithStream i o m r -> ConduitM i o m r instance GHC.Base.Functor (Data.Conduit.Internal.Fusion.Step s o) module Data.Conduit.Internal.List.Stream unfoldS :: Monad m => (b -> Maybe (a, b)) -> b -> StreamProducer m a unfoldEitherS :: Monad m => (b -> Either r (a, b)) -> b -> StreamConduitM i a m r unfoldMS :: Monad m => (b -> m (Maybe (a, b))) -> b -> StreamProducer m a unfoldEitherMS :: Monad m => (b -> m (Either r (a, b))) -> b -> StreamConduitM i a m r sourceListS :: Monad m => [a] -> StreamProducer m a enumFromToS :: (Enum a, Ord a, Monad m) => a -> a -> StreamProducer m a enumFromToS_int :: (Integral a, Monad m) => a -> a -> StreamProducer m a iterateS :: Monad m => (a -> a) -> a -> StreamProducer m a replicateS :: Monad m => Int -> a -> StreamProducer m a replicateMS :: Monad m => Int -> m a -> StreamProducer m a foldS :: Monad m => (b -> a -> b) -> b -> StreamConsumer a m b foldMS :: Monad m => (b -> a -> m b) -> b -> StreamConsumer a m b mapM_S :: Monad m => (a -> m ()) -> StreamConsumer a m () dropS :: Monad m => Int -> StreamConsumer a m () takeS :: Monad m => Int -> StreamConsumer a m [a] headS :: Monad m => StreamConsumer a m (Maybe a) mapS :: Monad m => (a -> b) -> StreamConduit a m b mapMS :: Monad m => (a -> m b) -> StreamConduit a m b iterMS :: Monad m => (a -> m ()) -> StreamConduit a m a mapMaybeS :: Monad m => (a -> Maybe b) -> StreamConduit a m b mapMaybeMS :: Monad m => (a -> m (Maybe b)) -> StreamConduit a m b catMaybesS :: Monad m => StreamConduit (Maybe a) m a concatS :: (Monad m, Foldable f) => StreamConduit (f a) m a concatMapS :: Monad m => (a -> [b]) -> StreamConduit a m b concatMapMS :: Monad m => (a -> m [b]) -> StreamConduit a m b concatMapAccumS :: Monad m => (a -> accum -> (accum, [b])) -> accum -> StreamConduit a m b mapAccumS :: Monad m => (a -> s -> (s, b)) -> s -> StreamConduitM a b m s mapAccumMS :: Monad m => (a -> s -> m (s, b)) -> s -> StreamConduitM a b m s concatMapAccumMS :: Monad m => (a -> accum -> m (accum, [b])) -> accum -> StreamConduit a m b mapFoldableS :: (Monad m, Foldable f) => (a -> f b) -> StreamConduit a m b mapFoldableMS :: (Monad m, Foldable f) => (a -> m (f b)) -> StreamConduit a m b consumeS :: Monad m => StreamConsumer a m [a] groupByS :: Monad m => (a -> a -> Bool) -> StreamConduit a m [a] groupOn1S :: (Monad m, Eq b) => (a -> b) -> StreamConduit a m (a, [a]) data GroupByState a b s GBStart :: s -> GroupByState a b s GBLoop :: ([a] -> [a]) -> a -> b -> s -> GroupByState a b s GBDone :: GroupByState a b s groupBy1S :: Monad m => (a -> b) -> (b -> b -> Bool) -> StreamConduit a m (a, [a]) isolateS :: Monad m => Int -> StreamConduit a m a filterS :: Monad m => (a -> Bool) -> StreamConduit a m a sinkNullS :: Monad m => StreamConsumer a m () sourceNullS :: Monad m => StreamProducer m a -- | If this is your first time with conduit, you should probably start -- with the tutorial: https://github.com/snoyberg/conduit#readme. module Data.Conduit -- | Provides a stream of output values, without consuming any input or -- producing a final result. -- -- Since 0.5.0 type Source m o = ConduitM () o m () -- | Consumes a stream of input values and produces a stream of output -- values, without producing a final result. -- -- Since 0.5.0 type Conduit i m o = ConduitM i o m () -- | Consumes a stream of input values and produces a final result, without -- producing any output. -- --
--   type Sink i m r = ConduitM i Void m r
--   
-- -- Since 0.5.0 type Sink i = ConduitM i Void -- | Core datatype of the conduit package. This type represents a general -- component which can consume a stream of input values i, -- produce a stream of output values o, perform actions in the -- m monad, and produce a final result r. The type -- synonyms provided here are simply wrappers around this type. -- -- Since 1.0.0 data ConduitM i o m r -- | Combine two Conduits together into a new Conduit -- (aka fuse). -- -- Output from the upstream (left) conduit will be fed into the -- downstream (right) conduit. Processing will terminate when downstream -- (right) returns. Leftover data returned from the right -- Conduit will be discarded. (.|) :: Monad m => ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r infixr 2 .| -- | The connect operator, which pulls data from a source and pushes to a -- sink. If you would like to keep the Source open to be used -- for other operations, use the connect-and-resume operator $$+. -- -- Since 0.4.0 ($$) :: Monad m => Source m a -> Sink a m b -> m b infixr 0 $$ -- | A synonym for =$= for backwards compatibility. -- -- Since 0.4.0 ($=) :: Monad m => Conduit a m b -> ConduitM b c m r -> ConduitM a c m r infixl 1 $= -- | A synonym for =$= for backwards compatibility. -- -- Since 0.4.0 (=$) :: Monad m => Conduit a m b -> ConduitM b c m r -> ConduitM a c m r infixr 2 =$ -- | Fusion operator, combining two Conduits together into a new -- Conduit. -- -- Both Conduits will be closed when the newly-created -- Conduit is closed. -- -- Leftover data returned from the right Conduit will be -- discarded. -- -- Since 0.4.0 (=$=) :: Monad m => Conduit a m b -> ConduitM b c m r -> ConduitM a c m r infixr 2 =$= -- | Named function synonym for $$. -- -- Since 1.2.3 connect :: Monad m => Source m a -> Sink a m b -> m b -- | Named function synonym for =$=. -- -- Since 1.2.3 fuse :: Monad m => Conduit a m b -> ConduitM b c m r -> ConduitM a c m r -- | Fuse two ConduitMs together, and provide the return value of -- both. Note that this will force the entire upstream ConduitM -- to be run to produce the result value, even if the downstream -- terminates early. -- -- Since 1.1.5 fuseBoth :: Monad m => ConduitM a b m r1 -> ConduitM b c m r2 -> ConduitM a c m (r1, r2) -- | Like fuseBoth, but does not force consumption of the -- Producer. In the case that the Producer terminates, -- the result value is provided as a Just value. If it does not -- terminate, then a Nothing value is returned. -- -- One thing to note here is that "termination" here only occurs if the -- Producer actually yields a Nothing value. For -- example, with the Producer mapM_ yield [1..5], if -- five values are requested, the Producer has not yet -- terminated. Termination only occurs when the sixth value is awaited -- for and the Producer signals termination. -- -- Since 1.2.4 fuseBothMaybe :: Monad m => ConduitM a b m r1 -> ConduitM b c m r2 -> ConduitM a c m (Maybe r1, r2) -- | Same as fuseBoth, but ignore the return value from the -- downstream Conduit. Same caveats of forced consumption apply. -- -- Since 1.1.5 fuseUpstream :: Monad m => ConduitM a b m r -> Conduit b m c -> ConduitM a c m r -- | Wait for a single input value from upstream. If no data is available, -- returns Nothing. Once await returns -- Nothing, subsequent calls will also return Nothing. -- -- Since 0.5.0 await :: Monad m => Consumer i m (Maybe i) -- | Send a value downstream to the next component to consume. If the -- downstream component terminates, this call will never return control. -- If you would like to register a cleanup function, please use -- yieldOr instead. -- -- Since 0.5.0 yield :: Monad m => o -> ConduitM i o m () -- | Send a monadic value downstream for the next component to consume. yieldM :: Monad m => m o -> ConduitM i o m () -- | Provide a single piece of leftover input to be consumed by the next -- component in the current monadic binding. -- -- Note: it is highly encouraged to only return leftover values -- from input already consumed from upstream. leftover :: i -> ConduitM i o m () -- | Run a pipeline until processing completes. -- -- Since 1.2.1 runConduit :: Monad m => ConduitM () Void m r -> m r -- | Run a pure pipeline until processing completes, i.e. a pipeline with -- Identity as the base monad. This is equivalient to -- runIdentity . runConduit. runConduitPure :: ConduitM () Void Identity r -> r -- | Run a pipeline which acquires resources with ResourceT, and -- then run the ResourceT transformer. This is equivalent to -- runResourceT . runConduit. runConduitRes :: MonadBaseControl IO m => ConduitM () Void (ResourceT m) r -> m r -- | Bracket a conduit computation between allocation and release of a -- resource. Two guarantees are given about resource finalization: -- --
    --
  1. It will be prompt. The finalization will be run as early as -- possible.
  2. --
  3. It is exception safe. Due to usage of resourcet, the -- finalization will be run in the event of any exceptions.
  4. --
-- -- Since 0.5.0 bracketP :: MonadResource m => IO a -> (a -> IO ()) -> (a -> ConduitM i o m r) -> ConduitM i o m r -- | Add some code to be run when the given component cleans up. -- -- The supplied cleanup function will be given a True if the -- component ran to completion, or False if it terminated early -- due to a downstream component terminating. -- -- Note that this function is not exception safe. For that, please use -- bracketP. -- -- Since 0.4.1 addCleanup :: Monad m => (Bool -> m ()) -> ConduitM i o m r -> ConduitM i o m r -- | Similar to yield, but additionally takes a finalizer to be run -- if the downstream component terminates. -- -- Since 0.5.0 yieldOr :: Monad m => o -> m () -> ConduitM i o m () -- | Catch all exceptions thrown by the current component of the pipeline. -- -- Note: this will not catch exceptions thrown by other -- components! For example, if an exception is thrown in a -- Source feeding to a Sink, and the Sink uses -- catchC, the exception will not be caught. -- -- Due to this behavior (as well as lack of async exception safety), you -- should not try to implement combinators such as onException -- in terms of this primitive function. -- -- Note also that the exception handling will not be applied to -- any finalizers generated by this conduit. -- -- Since 1.0.11 catchC :: (MonadBaseControl IO m, Exception e) => ConduitM i o m r -> (e -> ConduitM i o m r) -> ConduitM i o m r -- | The same as flip catchC. -- -- Since 1.0.11 handleC :: (MonadBaseControl IO m, Exception e) => (e -> ConduitM i o m r) -> ConduitM i o m r -> ConduitM i o m r -- | A version of try for use within a pipeline. See the comments -- in catchC for more details. -- -- Since 1.0.11 tryC :: (MonadBaseControl IO m, Exception e) => ConduitM i o m r -> ConduitM i o m (Either e r) -- | A component which produces a stream of output values, regardless of -- the input stream. A Producer is a generalization of a -- Source, and can be used as either a Source or a -- Conduit. -- -- Since 1.0.0 type Producer m o = forall i. ConduitM i o m () -- | A component which consumes a stream of input values and produces a -- final result, regardless of the output stream. A Consumer is -- a generalization of a Sink, and can be used as either a -- Sink or a Conduit. -- -- Since 1.0.0 type Consumer i m r = forall o. ConduitM i o m r -- | Generalize a Source to a Producer. -- -- Since 1.0.0 toProducer :: Monad m => Source m a -> Producer m a -- | Generalize a Sink to a Consumer. -- -- Since 1.0.0 toConsumer :: Monad m => Sink a m b -> Consumer a m b -- | Wait for input forever, calling the given inner component for each -- piece of new input. -- -- This function is provided as a convenience for the common pattern of -- awaiting input, checking if it's Just and then -- looping. -- -- Since 0.5.0 awaitForever :: Monad m => (i -> ConduitM i o m r) -> ConduitM i o m () -- | Transform the monad that a ConduitM lives in. -- -- Note that the monad transforming function will be run multiple times, -- resulting in unintuitive behavior in some cases. For a fuller -- treatment, please see: -- -- -- https://github.com/snoyberg/conduit/wiki/Dealing-with-monad-transformers -- -- This function is just a synonym for hoist. -- -- Since 0.4.0 transPipe :: Monad m => (forall a. m a -> n a) -> ConduitM i o m r -> ConduitM i o n r -- | Apply a function to all the output values of a ConduitM. -- -- This mimics the behavior of fmap for a Source and -- Conduit in pre-0.4 days. It can also be simulated by fusing -- with the map conduit from Data.Conduit.List. -- -- Since 0.4.1 mapOutput :: Monad m => (o1 -> o2) -> ConduitM i o1 m r -> ConduitM i o2 m r -- | Same as mapOutput, but use a function that returns -- Maybe values. -- -- Since 0.5.0 mapOutputMaybe :: Monad m => (o1 -> Maybe o2) -> ConduitM i o1 m r -> ConduitM i o2 m r -- | Apply a function to all the input values of a ConduitM. -- -- Since 0.5.0 mapInput :: Monad m => (i1 -> i2) -> (i2 -> Maybe i1) -> ConduitM i2 o m r -> ConduitM i1 o m r -- | Merge a Source into a Conduit. The new conduit will -- stop processing once either source or upstream have been exhausted. mergeSource :: Monad m => Source m i -> Conduit a m (i, a) -- | Turn a Sink into a Conduit in the following way: -- -- -- -- Note that the Sink will stop receiving input as soon as the -- downstream it is connected to shuts down. -- -- An example usage would be to write the result of a Sink to -- some mutable variable while allowing other processing to continue. -- -- Since 1.1.0 passthroughSink :: Monad m => Sink i m r -> (r -> m ()) -> Conduit i m i -- | Convert a Source into a list. The basic functionality can be -- explained as: -- --
--   sourceToList src = src $$ Data.Conduit.List.consume
--   
-- -- However, sourceToList is able to produce its results lazily, -- which cannot be done when running a conduit pipeline in general. -- Unlike the Data.Conduit.Lazy module (in conduit-extra), this -- function performs no unsafe I/O operations, and therefore can only be -- as lazily as the underlying monad. -- -- Since 1.2.6 sourceToList :: Monad m => Source m a -> m [a] -- | A Source which has been started, but has not yet completed. -- -- This type contains both the current state of the Source, and -- the finalizer to be run to close it. -- -- Since 0.5.0 data ResumableSource m o -- | Turn a Source into a ResumableSource with no -- attached finalizer. -- -- Since 1.1.4 newResumableSource :: Monad m => Source m o -> ResumableSource m o -- | The connect-and-resume operator. This does not close the -- Source, but instead returns it to be used again. This allows -- a Source to be used incrementally in a large program, without -- forcing the entire program to live in the Sink monad. -- -- Mnemonic: connect + do more. -- -- Since 0.5.0 ($$+) :: Monad m => Source m a -> Sink a m b -> m (ResumableSource m a, b) infixr 0 $$+ -- | Continue processing after usage of $$+. -- -- Since 0.5.0 ($$++) :: Monad m => ResumableSource m a -> Sink a m b -> m (ResumableSource m a, b) infixr 0 $$++ -- | Complete processing of a ResumableSource. This will run the -- finalizer associated with the ResumableSource. In order to -- guarantee process resource finalization, you must use this -- operator after using $$+ and $$++. -- -- Since 0.5.0 ($$+-) :: Monad m => ResumableSource m a -> Sink a m b -> m b infixr 0 $$+- -- | Left fusion for a resumable source. -- -- Since 1.0.16 ($=+) :: Monad m => ResumableSource m a -> Conduit a m b -> ResumableSource m b infixl 1 $=+ -- | Unwraps a ResumableSource into a Source and a -- finalizer. -- -- A ResumableSource represents a Source which has -- already been run, and therefore has a finalizer registered. As a -- result, if we want to turn it into a regular Source, we need -- to ensure that the finalizer will be run appropriately. By -- appropriately, I mean: -- -- -- -- This function returns both a Source and a finalizer which -- ensures that the above two conditions hold. Once you call that -- finalizer, the Source is invalidated and cannot be used. -- -- Since 0.5.2 unwrapResumable :: MonadIO m => ResumableSource m o -> m (Source m o, m ()) -- | Execute the finalizer associated with a ResumableSource, -- rendering the ResumableSource invalid for further use. -- -- This is just a more explicit version of $$+- return (). -- -- Since 1.1.3 closeResumableSource :: Monad m => ResumableSource m a -> m () -- | A generalization of ResumableSource. Allows to resume an -- arbitrary conduit, keeping its state and using it later (or finalizing -- it). -- -- Since 1.0.17 data ResumableConduit i m o -- | Turn a Conduit into a ResumableConduit with no -- attached finalizer. -- -- Since 1.1.4 newResumableConduit :: Monad m => Conduit i m o -> ResumableConduit i m o -- | The connect-and-resume operator. This does not close the -- Conduit, but instead returns it to be used again. This allows -- a Conduit to be used incrementally in a large program, -- without forcing the entire program to live in the Sink monad. -- -- Leftover data returned from the Sink will be discarded. -- -- Mnemonic: connect + do more. -- -- Since 1.0.17 (=$$+) :: Monad m => Conduit a m b -> Sink b m r -> Sink a m (ResumableConduit a m b, r) infixr 0 =$$+ -- | Continue processing after usage of =$$+. Connect a -- ResumableConduit to a sink and return the output of the sink -- together with a new ResumableConduit. -- -- Since 1.0.17 (=$$++) :: Monad m => ResumableConduit i m o -> Sink o m r -> Sink i m (ResumableConduit i m o, r) infixr 0 =$$++ -- | Complete processing of a ResumableConduit. This will run the -- finalizer associated with the ResumableConduit. In order to -- guarantee process resource finalization, you must use this -- operator after using =$$+ and =$$++. -- -- Since 1.0.17 (=$$+-) :: Monad m => ResumableConduit i m o -> Sink o m r -> Sink i m r infixr 0 =$$+- -- | Unwraps a ResumableConduit into a Conduit and a -- finalizer. -- -- Since unwrapResumable for more information. -- -- Since 1.0.17 unwrapResumableConduit :: MonadIO m => ResumableConduit i m o -> m (Conduit i m o, m ()) -- | Similar to fuseReturnLeftovers, but use the provided function -- to convert downstream leftovers to upstream leftovers. -- -- Since 1.0.17 fuseLeftovers :: Monad m => ([b] -> [a]) -> ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r -- | Same as normal fusion (e.g. =$=), except instead of -- discarding leftovers from the downstream component, return them. -- -- Since 1.0.17 fuseReturnLeftovers :: Monad m => ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m (r, [b]) -- | Provide for a stream of data that can be flushed. -- -- A number of Conduits (e.g., zlib compression) need the -- ability to flush the stream at some point. This provides a single -- wrapper datatype to be used in all such circumstances. -- -- Since 0.3.0 data Flush a Chunk :: a -> Flush a Flush :: Flush a -- | A wrapper for defining an Applicative instance for -- Sources which allows to combine sources together, generalizing -- zipSources. A combined source will take input yielded from each -- of its Sources until any of them stop producing output. -- -- Since 1.0.13 newtype ZipSource m o ZipSource :: Source m o -> ZipSource m o [getZipSource] :: ZipSource m o -> Source m o -- | Coalesce all values yielded by all of the Sources. -- -- Implemented on top of ZipSource and as such, it exhibits the -- same short-circuiting behavior as ZipSource. See that data -- type for more details. If you want to create a source that yields -- *all* values from multiple sources, use sequence_. -- -- Since 1.0.13 sequenceSources :: (Traversable f, Monad m) => f (Source m o) -> Source m (f o) -- | 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 -- --
--   sequenceSinks :: (Monad m)
--             => [Sink i m r] -> Sink i m [r]
--   sequenceSinks = 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. -- -- This newtype is in fact a type constrained version of -- ZipConduit, and has the same behavior. It's presented as a -- separate type since (1) it historically predates ZipConduit, -- and (2) the type constraining can make your code clearer (and thereby -- make your error messages more easily understood). -- -- Since 1.0.13 newtype ZipSink i m r ZipSink :: Sink i m r -> ZipSink i m r [getZipSink] :: ZipSink i m r -> Sink i m r -- | Send incoming values to all of the Sink providing, and -- ultimately coalesce together all return values. -- -- Implemented on top of ZipSink, see that data type for more -- details. -- -- Since 1.0.13 sequenceSinks :: (Traversable f, Monad m) => f (Sink i m r) -> Sink i m (f 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 newtype ZipConduit i o m r ZipConduit :: ConduitM i o m r -> ZipConduit i o m r [getZipConduit] :: ZipConduit i o m r -> ConduitM i o m 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 sequenceConduits :: (Traversable f, Monad m) => f (ConduitM i o m r) -> ConduitM i o m (f r) module Data.Conduit.Internal -- | The underlying datatype for all the types in this package. In has six -- type parameters: -- -- -- -- A basic intuition is that every Pipe produces a stream of -- output values (o), and eventually indicates that this stream is -- terminated by sending a result (r). On the receiving end of a -- Pipe, these become the i and u parameters. -- -- Since 0.5.0 data Pipe l i o u m r -- | Provide new output to be sent downstream. This constructor has three -- fields: the next Pipe to be used, a finalization function, -- and the output value. HaveOutput :: (Pipe l i o u m r) -> (m ()) -> o -> Pipe l i o u m r -- | Request more input from upstream. The first field takes a new input -- value and provides a new Pipe. The second takes an upstream -- result value, which indicates that upstream is producing no more -- results. NeedInput :: (i -> Pipe l i o u m r) -> (u -> Pipe l i o u m r) -> Pipe l i o u m r -- | Processing with this Pipe is complete, providing the final -- result. Done :: r -> Pipe l i o u m r -- | Require running of a monadic action to get the next Pipe. PipeM :: (m (Pipe l i o u m r)) -> Pipe l i o u m r -- | Return leftover input, which should be provided to future operations. Leftover :: (Pipe l i o u m r) -> l -> Pipe l i o u m r -- | Wait for a single input value from upstream. -- -- Since 0.5.0 await :: Pipe l i o u m (Maybe i) -- | This is similar to await, but will return the upstream result -- value as Left if available. -- -- Since 0.5.0 awaitE :: Pipe l i o u m (Either u i) -- | Wait for input forever, calling the given inner Pipe for each -- piece of new input. Returns the upstream result type. -- -- Since 0.5.0 awaitForever :: Monad m => (i -> Pipe l i o r m r') -> Pipe l i o r m r -- | Send a single output value downstream. If the downstream Pipe -- terminates, this Pipe will terminate as well. -- -- Since 0.5.0 yield :: Monad m => o -> Pipe l i o u m () yieldM :: Monad m => m o -> Pipe l i o u m () -- | Similar to yield, but additionally takes a finalizer to be -- run if the downstream Pipe terminates. -- -- Since 0.5.0 yieldOr :: Monad m => o -> m () -> Pipe l i o u m () -- | Provide a single piece of leftover input to be consumed by the next -- pipe in the current monadic binding. -- -- Note: it is highly encouraged to only return leftover values -- from input already consumed from upstream. -- -- Since 0.5.0 leftover :: l -> Pipe l i o u m () -- | Bracket a pipe computation between allocation and release of a -- resource. Two guarantees are given about resource finalization: -- --
    --
  1. It will be prompt. The finalization will be run as early as -- possible.
  2. --
  3. It is exception safe. Due to usage of resourcet, the -- finalization will be run in the event of any exceptions.
  4. --
-- -- Since 0.5.0 bracketP :: MonadResource m => IO a -> (a -> IO ()) -> (a -> Pipe l i o u m r) -> Pipe l i o u m r -- | Add some code to be run when the given Pipe cleans up. -- -- Since 0.4.1 addCleanup :: Monad m => (Bool -> m ()) -> Pipe l i o u m r -> Pipe l i o u m r -- | The identity Pipe. -- -- Since 0.5.0 idP :: Monad m => Pipe l a a r m r -- | Compose a left and right pipe together into a complete pipe. The left -- pipe will be automatically closed when the right pipe finishes. -- -- Since 0.5.0 pipe :: Monad m => Pipe l a b r0 m r1 -> Pipe Void b c r1 m r2 -> Pipe l a c r0 m r2 -- | Same as pipe, but automatically applies injectLeftovers -- to the right Pipe. -- -- Since 0.5.0 pipeL :: Monad m => Pipe l a b r0 m r1 -> Pipe b b c r1 m r2 -> Pipe l a c r0 m r2 -- | Run a pipeline until processing completes. -- -- Since 0.5.0 runPipe :: Monad m => Pipe Void () Void () m r -> m r -- | Transforms a Pipe that provides leftovers to one which does -- not, allowing it to be composed. -- -- This function will provide any leftover values within this -- Pipe to any calls to await. If there are more -- leftover values than are demanded, the remainder are discarded. -- -- Since 0.5.0 injectLeftovers :: Monad m => Pipe i i o u m r -> Pipe l i o u m r -- | Fuse together two Pipes, connecting the output from the left -- to the input of the right. -- -- Notice that the leftover parameter for the Pipes must -- be Void. This ensures that there is no accidental data loss -- of leftovers during fusion. If you have a Pipe with -- leftovers, you must first call injectLeftovers. -- -- Since 0.5.0 (>+>) :: Monad m => Pipe l a b r0 m r1 -> Pipe Void b c r1 m r2 -> Pipe l a c r0 m r2 infixl 9 >+> -- | Same as >+>, but reverse the order of the arguments. -- -- Since 0.5.0 (<+<) :: Monad m => Pipe Void b c r1 m r2 -> Pipe l a b r0 m r1 -> Pipe l a c r0 m r2 infixr 9 <+< -- | See catchC for more details. -- -- Since 1.0.11 catchP :: (MonadBaseControl IO m, Exception e) => Pipe l i o u m r -> (e -> Pipe l i o u m r) -> Pipe l i o u m r -- | The same as flip catchP. -- -- Since 1.0.11 handleP :: (MonadBaseControl IO m, Exception e) => (e -> Pipe l i o u m r) -> Pipe l i o u m r -> Pipe l i o u m r -- | See tryC for more details. -- -- Since 1.0.11 tryP :: (MonadBaseControl IO m, Exception e) => Pipe l i o u m r -> Pipe l i o u m (Either e r) -- | Transform the monad that a Pipe lives in. -- -- Note that the monad transforming function will be run multiple times, -- resulting in unintuitive behavior in some cases. For a fuller -- treatment, please see: -- -- -- https://github.com/snoyberg/conduit/wiki/Dealing-with-monad-transformers -- -- This function is just a synonym for hoist. -- -- Since 0.4.0 transPipe :: Monad m => (forall a. m a -> n a) -> Pipe l i o u m r -> Pipe l i o u n r -- | Apply a function to all the output values of a Pipe. -- -- This mimics the behavior of fmap for a Source and -- Conduit in pre-0.4 days. -- -- Since 0.4.1 mapOutput :: Monad m => (o1 -> o2) -> Pipe l i o1 u m r -> Pipe l i o2 u m r -- | Same as mapOutput, but use a function that returns -- Maybe values. -- -- Since 0.5.0 mapOutputMaybe :: Monad m => (o1 -> Maybe o2) -> Pipe l i o1 u m r -> Pipe l i o2 u m r -- | Apply a function to all the input values of a Pipe. -- -- Since 0.5.0 mapInput :: Monad m => (i1 -> i2) -> (l2 -> Maybe l1) -> Pipe l2 i2 o u m r -> Pipe l1 i1 o u m r -- | Convert a list into a source. -- -- Since 0.3.0 sourceList :: Monad m => [a] -> Pipe l i a u m () -- | Returns a tuple of the upstream and downstream results. Note that this -- will force consumption of the entire input stream. -- -- Since 0.5.0 withUpstream :: Monad m => Pipe l i o u m r -> Pipe l i o u m (u, r) enumFromTo :: (Enum o, Eq o, Monad m) => o -> o -> Pipe l i o u m () -- | Generalize the upstream return value for a Pipe from unit to -- any type. -- -- Since 1.1.5 generalizeUpstream :: Monad m => Pipe l i o () m r -> Pipe l i o u m r -- | Core datatype of the conduit package. This type represents a general -- component which can consume a stream of input values i, -- produce a stream of output values o, perform actions in the -- m monad, and produce a final result r. The type -- synonyms provided here are simply wrappers around this type. -- -- Since 1.0.0 newtype ConduitM i o m r ConduitM :: (forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b) -> ConduitM i o m r [unConduitM] :: ConduitM i o m r -> forall b. (r -> Pipe i i o () m b) -> Pipe i i o () m b -- | Provides a stream of output values, without consuming any input or -- producing a final result. -- -- Since 0.5.0 type Source m o = ConduitM () o m () -- | A component which produces a stream of output values, regardless of -- the input stream. A Producer is a generalization of a -- Source, and can be used as either a Source or a -- Conduit. -- -- Since 1.0.0 type Producer m o = forall i. ConduitM i o m () -- | Consumes a stream of input values and produces a final result, without -- producing any output. -- --
--   type Sink i m r = ConduitM i Void m r
--   
-- -- Since 0.5.0 type Sink i = ConduitM i Void -- | A component which consumes a stream of input values and produces a -- final result, regardless of the output stream. A Consumer is -- a generalization of a Sink, and can be used as either a -- Sink or a Conduit. -- -- Since 1.0.0 type Consumer i m r = forall o. ConduitM i o m r -- | Consumes a stream of input values and produces a stream of output -- values, without producing a final result. -- -- Since 0.5.0 type Conduit i m o = ConduitM i o m () -- | A Source which has been started, but has not yet completed. -- -- This type contains both the current state of the Source, and -- the finalizer to be run to close it. -- -- Since 0.5.0 data ResumableSource m o ResumableSource :: (Pipe () () o () m ()) -> (m ()) -> ResumableSource m o -- | A generalization of ResumableSource. Allows to resume an -- arbitrary conduit, keeping its state and using it later (or finalizing -- it). -- -- Since 1.0.17 data ResumableConduit i m o ResumableConduit :: (Pipe i i o () m ()) -> (m ()) -> ResumableConduit i m o -- | Provide for a stream of data that can be flushed. -- -- A number of Conduits (e.g., zlib compression) need the -- ability to flush the stream at some point. This provides a single -- wrapper datatype to be used in all such circumstances. -- -- Since 0.3.0 data Flush a Chunk :: a -> Flush a Flush :: Flush a -- | A wrapper for defining an Applicative instance for -- Sources which allows to combine sources together, generalizing -- zipSources. A combined source will take input yielded from each -- of its Sources until any of them stop producing output. -- -- Since 1.0.13 newtype ZipSource m o ZipSource :: Source m o -> ZipSource m o [getZipSource] :: ZipSource m o -> Source m o -- | 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 -- --
--   sequenceSinks :: (Monad m)
--             => [Sink i m r] -> Sink i m [r]
--   sequenceSinks = 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. -- -- This newtype is in fact a type constrained version of -- ZipConduit, and has the same behavior. It's presented as a -- separate type since (1) it historically predates ZipConduit, -- and (2) the type constraining can make your code clearer (and thereby -- make your error messages more easily understood). -- -- Since 1.0.13 newtype ZipSink i m r ZipSink :: Sink i m r -> ZipSink i m r [getZipSink] :: ZipSink i m r -> Sink i 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 newtype ZipConduit i o m r ZipConduit :: ConduitM i o m r -> ZipConduit i o m r [getZipConduit] :: ZipConduit i o m r -> ConduitM i o m r -- | Wait for a single input value from upstream. If no data is available, -- returns Nothing. Once await returns -- Nothing, subsequent calls will also return Nothing. -- -- Since 0.5.0 await :: Monad m => Consumer i m (Maybe i) -- | Wait for input forever, calling the given inner component for each -- piece of new input. -- -- This function is provided as a convenience for the common pattern of -- awaiting input, checking if it's Just and then -- looping. -- -- Since 0.5.0 awaitForever :: Monad m => (i -> ConduitM i o m r) -> ConduitM i o m () -- | Send a value downstream to the next component to consume. If the -- downstream component terminates, this call will never return control. -- If you would like to register a cleanup function, please use -- yieldOr instead. -- -- Since 0.5.0 yield :: Monad m => o -> ConduitM i o m () -- | Send a monadic value downstream for the next component to consume. yieldM :: Monad m => m o -> ConduitM i o m () -- | Similar to yield, but additionally takes a finalizer to be run -- if the downstream component terminates. -- -- Since 0.5.0 yieldOr :: Monad m => o -> m () -> ConduitM i o m () -- | Provide a single piece of leftover input to be consumed by the next -- component in the current monadic binding. -- -- Note: it is highly encouraged to only return leftover values -- from input already consumed from upstream. leftover :: i -> ConduitM i o m () -- | Run a pipeline until processing completes. -- -- Since 1.2.1 runConduit :: Monad m => ConduitM () Void m r -> m r -- | Connect a Source to a Sink until the latter closes. -- Returns both the most recent state of the Source and the -- result of the Sink. -- -- We use a ResumableSource to keep track of the most recent -- finalizer provided by the Source. -- -- Since 0.5.0 connectResume :: Monad m => ResumableSource m o -> Sink o m r -> m (ResumableSource m o, r) -- | Connect a ResumableConduit to a sink and return the output of -- the sink together with a new ResumableConduit. -- -- Since 1.0.17 connectResumeConduit :: Monad m => ResumableConduit i m o -> Sink o m r -> Sink i m (ResumableConduit i m o, r) -- | Similar to fuseReturnLeftovers, but use the provided function -- to convert downstream leftovers to upstream leftovers. -- -- Since 1.0.17 fuseLeftovers :: Monad m => ([b] -> [a]) -> ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m r -- | Same as normal fusion (e.g. =$=), except instead of -- discarding leftovers from the downstream component, return them. -- -- Since 1.0.17 fuseReturnLeftovers :: Monad m => ConduitM a b m () -> ConduitM b c m r -> ConduitM a c m (r, [b]) -- | The connect-and-resume operator. This does not close the -- Source, but instead returns it to be used again. This allows -- a Source to be used incrementally in a large program, without -- forcing the entire program to live in the Sink monad. -- -- Mnemonic: connect + do more. -- -- Since 0.5.0 ($$+) :: Monad m => Source m a -> Sink a m b -> m (ResumableSource m a, b) infixr 0 $$+ -- | Continue processing after usage of $$+. -- -- Since 0.5.0 ($$++) :: Monad m => ResumableSource m a -> Sink a m b -> m (ResumableSource m a, b) infixr 0 $$++ -- | Complete processing of a ResumableSource. This will run the -- finalizer associated with the ResumableSource. In order to -- guarantee process resource finalization, you must use this -- operator after using $$+ and $$++. -- -- Since 0.5.0 ($$+-) :: Monad m => ResumableSource m a -> Sink a m b -> m b infixr 0 $$+- -- | Left fusion for a resumable source. -- -- Since 1.0.16 ($=+) :: Monad m => ResumableSource m a -> Conduit a m b -> ResumableSource m b infixl 1 $=+ -- | The connect-and-resume operator. This does not close the -- Conduit, but instead returns it to be used again. This allows -- a Conduit to be used incrementally in a large program, -- without forcing the entire program to live in the Sink monad. -- -- Leftover data returned from the Sink will be discarded. -- -- Mnemonic: connect + do more. -- -- Since 1.0.17 (=$$+) :: Monad m => Conduit a m b -> Sink b m r -> Sink a m (ResumableConduit a m b, r) infixr 0 =$$+ -- | Continue processing after usage of =$$+. Connect a -- ResumableConduit to a sink and return the output of the sink -- together with a new ResumableConduit. -- -- Since 1.0.17 (=$$++) :: Monad m => ResumableConduit i m o -> Sink o m r -> Sink i m (ResumableConduit i m o, r) infixr 0 =$$++ -- | Complete processing of a ResumableConduit. This will run the -- finalizer associated with the ResumableConduit. In order to -- guarantee process resource finalization, you must use this -- operator after using =$$+ and =$$++. -- -- Since 1.0.17 (=$$+-) :: Monad m => ResumableConduit i m o -> Sink o m r -> Sink i m r infixr 0 =$$+- -- | The connect operator, which pulls data from a source and pushes to a -- sink. If you would like to keep the Source open to be used -- for other operations, use the connect-and-resume operator $$+. -- -- Since 0.4.0 ($$) :: Monad m => Source m a -> Sink a m b -> m b infixr 0 $$ -- | A synonym for =$= for backwards compatibility. -- -- Since 0.4.0 ($=) :: Monad m => Conduit a m b -> ConduitM b c m r -> ConduitM a c m r infixl 1 $= -- | A synonym for =$= for backwards compatibility. -- -- Since 0.4.0 (=$) :: Monad m => Conduit a m b -> ConduitM b c m r -> ConduitM a c m r infixr 2 =$ -- | Fusion operator, combining two Conduits together into a new -- Conduit. -- -- Both Conduits will be closed when the newly-created -- Conduit is closed. -- -- Leftover data returned from the right Conduit will be -- discarded. -- -- Since 0.4.0 (=$=) :: Monad m => Conduit a m b -> ConduitM b c m r -> ConduitM a c m r infixr 2 =$= sourceToPipe :: Monad m => Source m o -> Pipe l i o u m () sinkToPipe :: Monad m => Sink i m r -> Pipe l i o u m r conduitToPipe :: Monad m => Conduit i m o -> Pipe l i o u m () -- | Generalize a Source to a Producer. -- -- Since 1.0.0 toProducer :: Monad m => Source m a -> Producer m a -- | Generalize a Sink to a Consumer. -- -- Since 1.0.0 toConsumer :: Monad m => Sink a m b -> Consumer a m b -- | Bracket a conduit computation between allocation and release of a -- resource. Two guarantees are given about resource finalization: -- --
    --
  1. It will be prompt. The finalization will be run as early as -- possible.
  2. --
  3. It is exception safe. Due to usage of resourcet, the -- finalization will be run in the event of any exceptions.
  4. --
-- -- Since 0.5.0 bracketP :: MonadResource m => IO a -> (a -> IO ()) -> (a -> ConduitM i o m r) -> ConduitM i o m r -- | Add some code to be run when the given component cleans up. -- -- The supplied cleanup function will be given a True if the -- component ran to completion, or False if it terminated early -- due to a downstream component terminating. -- -- Note that this function is not exception safe. For that, please use -- bracketP. -- -- Since 0.4.1 addCleanup :: Monad m => (Bool -> m ()) -> ConduitM i o m r -> ConduitM i o m r -- | Catch all exceptions thrown by the current component of the pipeline. -- -- Note: this will not catch exceptions thrown by other -- components! For example, if an exception is thrown in a -- Source feeding to a Sink, and the Sink uses -- catchC, the exception will not be caught. -- -- Due to this behavior (as well as lack of async exception safety), you -- should not try to implement combinators such as onException -- in terms of this primitive function. -- -- Note also that the exception handling will not be applied to -- any finalizers generated by this conduit. -- -- Since 1.0.11 catchC :: (MonadBaseControl IO m, Exception e) => ConduitM i o m r -> (e -> ConduitM i o m r) -> ConduitM i o m r -- | The same as flip catchC. -- -- Since 1.0.11 handleC :: (MonadBaseControl IO m, Exception e) => (e -> ConduitM i o m r) -> ConduitM i o m r -> ConduitM i o m r -- | A version of try for use within a pipeline. See the comments -- in catchC for more details. -- -- Since 1.0.11 tryC :: (MonadBaseControl IO m, Exception e) => ConduitM i o m r -> ConduitM i o m (Either e r) -- | Transform the monad that a ConduitM lives in. -- -- Note that the monad transforming function will be run multiple times, -- resulting in unintuitive behavior in some cases. For a fuller -- treatment, please see: -- -- -- https://github.com/snoyberg/conduit/wiki/Dealing-with-monad-transformers -- -- This function is just a synonym for hoist. -- -- Since 0.4.0 transPipe :: Monad m => (forall a. m a -> n a) -> ConduitM i o m r -> ConduitM i o n r -- | Apply a function to all the output values of a ConduitM. -- -- This mimics the behavior of fmap for a Source and -- Conduit in pre-0.4 days. It can also be simulated by fusing -- with the map conduit from Data.Conduit.List. -- -- Since 0.4.1 mapOutput :: Monad m => (o1 -> o2) -> ConduitM i o1 m r -> ConduitM i o2 m r -- | Same as mapOutput, but use a function that returns -- Maybe values. -- -- Since 0.5.0 mapOutputMaybe :: Monad m => (o1 -> Maybe o2) -> ConduitM i o1 m r -> ConduitM i o2 m r -- | Apply a function to all the input values of a ConduitM. -- -- Since 0.5.0 mapInput :: Monad m => (i1 -> i2) -> (i2 -> Maybe i1) -> ConduitM i2 o m r -> ConduitM i1 o m r -- | Execute the finalizer associated with a ResumableSource, -- rendering the ResumableSource invalid for further use. -- -- This is just a more explicit version of $$+- return (). -- -- Since 1.1.3 closeResumableSource :: Monad m => ResumableSource m a -> m () -- | Unwraps a ResumableSource into a Source and a -- finalizer. -- -- A ResumableSource represents a Source which has -- already been run, and therefore has a finalizer registered. As a -- result, if we want to turn it into a regular Source, we need -- to ensure that the finalizer will be run appropriately. By -- appropriately, I mean: -- -- -- -- This function returns both a Source and a finalizer which -- ensures that the above two conditions hold. Once you call that -- finalizer, the Source is invalidated and cannot be used. -- -- Since 0.5.2 unwrapResumable :: MonadIO m => ResumableSource m o -> m (Source m o, m ()) -- | Unwraps a ResumableConduit into a Conduit and a -- finalizer. -- -- Since unwrapResumable for more information. -- -- Since 1.0.17 unwrapResumableConduit :: MonadIO m => ResumableConduit i m o -> m (Conduit i m o, m ()) -- | Turn a Source into a ResumableSource with no -- attached finalizer. -- -- Since 1.1.4 newResumableSource :: Monad m => Source m o -> ResumableSource m o -- | Turn a Conduit into a ResumableConduit with no -- attached finalizer. -- -- Since 1.1.4 newResumableConduit :: Monad m => Conduit i m o -> ResumableConduit i m o -- | Combines two sinks. The new sink will complete when both input sinks -- have completed. -- -- Any leftovers are discarded. -- -- Since 0.4.1 zipSinks :: Monad m => Sink i m r -> Sink i m r' -> Sink i m (r, r') -- | Combines two sources. The new source will stop producing once either -- source has been exhausted. -- -- Since 1.0.13 zipSources :: Monad m => Source m a -> Source m b -> Source m (a, b) -- | Combines two sources. The new source will stop producing once either -- source has been exhausted. -- -- Since 1.0.13 zipSourcesApp :: Monad m => Source m (a -> b) -> Source m a -> Source m b -- | Since 1.0.17 zipConduitApp :: Monad m => ConduitM i o m (x -> y) -> ConduitM i o m x -> ConduitM i o m y -- | Merge a Source into a Conduit. The new conduit will -- stop processing once either source or upstream have been exhausted. mergeSource :: Monad m => Source m i -> Conduit a m (i, a) -- | Turn a Sink into a Conduit in the following way: -- -- -- -- Note that the Sink will stop receiving input as soon as the -- downstream it is connected to shuts down. -- -- An example usage would be to write the result of a Sink to -- some mutable variable while allowing other processing to continue. -- -- Since 1.1.0 passthroughSink :: Monad m => Sink i m r -> (r -> m ()) -> Conduit i m i -- | Convert a Source into a list. The basic functionality can be -- explained as: -- --
--   sourceToList src = src $$ Data.Conduit.List.consume
--   
-- -- However, sourceToList is able to produce its results lazily, -- which cannot be done when running a conduit pipeline in general. -- Unlike the Data.Conduit.Lazy module (in conduit-extra), this -- function performs no unsafe I/O operations, and therefore can only be -- as lazily as the underlying monad. -- -- Since 1.2.6 sourceToList :: Monad m => Source m a -> m [a] -- | Fuse two ConduitMs together, and provide the return value of -- both. Note that this will force the entire upstream ConduitM -- to be run to produce the result value, even if the downstream -- terminates early. -- -- Since 1.1.5 fuseBoth :: Monad m => ConduitM a b m r1 -> ConduitM b c m r2 -> ConduitM a c m (r1, r2) -- | Like fuseBoth, but does not force consumption of the -- Producer. In the case that the Producer terminates, -- the result value is provided as a Just value. If it does not -- terminate, then a Nothing value is returned. -- -- One thing to note here is that "termination" here only occurs if the -- Producer actually yields a Nothing value. For -- example, with the Producer mapM_ yield [1..5], if -- five values are requested, the Producer has not yet -- terminated. Termination only occurs when the sixth value is awaited -- for and the Producer signals termination. -- -- Since 1.2.4 fuseBothMaybe :: Monad m => ConduitM a b m r1 -> ConduitM b c m r2 -> ConduitM a c m (Maybe r1, r2) -- | Same as fuseBoth, but ignore the return value from the -- downstream Conduit. Same caveats of forced consumption apply. -- -- Since 1.1.5 fuseUpstream :: Monad m => ConduitM a b m r -> Conduit b m c -> ConduitM a c m r -- | Coalesce all values yielded by all of the Sources. -- -- Implemented on top of ZipSource and as such, it exhibits the -- same short-circuiting behavior as ZipSource. See that data -- type for more details. If you want to create a source that yields -- *all* values from multiple sources, use sequence_. -- -- Since 1.0.13 sequenceSources :: (Traversable f, Monad m) => f (Source m o) -> Source m (f o) -- | Send incoming values to all of the Sink providing, and -- ultimately coalesce together all return values. -- -- Implemented on top of ZipSink, see that data type for more -- details. -- -- Since 1.0.13 sequenceSinks :: (Traversable f, Monad m) => f (Sink i m r) -> Sink i 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 sequenceConduits :: (Traversable f, Monad m) => f (ConduitM i o m r) -> ConduitM i o m (f r) -- | Allow monad transformers to be run/eval/exec in a section of conduit -- rather then needing to run across the whole conduit. The circumvents -- many of the problems with breaking the monad transformer laws. For -- more information, see the announcement blog post: -- http://www.yesodweb.com/blog/2014/01/conduit-transformer-exception -- -- This module was added in conduit 1.0.11. module Data.Conduit.Lift -- | Wrap the base monad in ExceptT -- -- Since 1.2.12 exceptC :: (Monad m, Monad (t (ExceptT e m)), MonadTrans t, MFunctor t) => t m (Either e b) -> t (ExceptT e m) b -- | Run ExceptT in the base monad -- -- Since 1.2.12 runExceptC :: Monad m => ConduitM i o (ExceptT e m) r -> ConduitM i o m (Either e r) -- | Catch an error in the base monad -- -- Since 1.2.12 catchExceptC :: Monad m => ConduitM i o (ExceptT e m) r -> (e -> ConduitM i o (ExceptT e m) r) -> ConduitM i o (ExceptT e m) r -- | Wrap the base monad in ErrorT -- -- Since 1.0.11 errorC :: (Monad m, Monad (t (ErrorT e m)), MonadTrans t, Error e, MFunctor t) => t m (Either e b) -> t (ErrorT e m) b -- | Run ErrorT in the base monad -- -- Since 1.0.11 runErrorC :: (Monad m, Error e) => ConduitM i o (ErrorT e m) r -> ConduitM i o m (Either e r) -- | Catch an error in the base monad -- -- Since 1.0.11 catchErrorC :: (Monad m, Error e) => ConduitM i o (ErrorT e m) r -> (e -> ConduitM i o (ErrorT e m) r) -> ConduitM i o (ErrorT e m) r -- | Run CatchT in the base monad -- -- Since 1.1.0 runCatchC :: Monad m => ConduitM i o (CatchT m) r -> ConduitM i o m (Either SomeException r) -- | Catch an exception in the base monad -- -- Since 1.1.0 catchCatchC :: Monad m => ConduitM i o (CatchT m) r -> (SomeException -> ConduitM i o (CatchT m) r) -> ConduitM i o (CatchT m) r -- | Wrap the base monad in MaybeT -- -- Since 1.0.11 maybeC :: (Monad m, Monad (t (MaybeT m)), MonadTrans t, MFunctor t) => t m (Maybe b) -> t (MaybeT m) b -- | Run MaybeT in the base monad -- -- Since 1.0.11 runMaybeC :: Monad m => ConduitM i o (MaybeT m) r -> ConduitM i o m (Maybe r) -- | Wrap the base monad in ReaderT -- -- Since 1.0.11 readerC :: (Monad m, Monad (t1 (ReaderT t m)), MonadTrans t1, MFunctor t1) => (t -> t1 m b) -> t1 (ReaderT t m) b -- | Run ReaderT in the base monad -- -- Since 1.0.11 runReaderC :: Monad m => r -> ConduitM i o (ReaderT r m) res -> ConduitM i o m res -- | Wrap the base monad in StateT -- -- Since 1.0.11 stateLC :: (Monad m, Monad (t1 (StateT t m)), MonadTrans t1, MFunctor t1) => (t -> t1 m (b, t)) -> t1 (StateT t m) b -- | Run StateT in the base monad -- -- Since 1.0.11 runStateLC :: Monad m => s -> ConduitM i o (StateT s m) r -> ConduitM i o m (r, s) -- | Evaluate StateT in the base monad -- -- Since 1.0.11 evalStateLC :: Monad m => s -> ConduitM i o (StateT s m) r -> ConduitM i o m r -- | Execute StateT in the base monad -- -- Since 1.0.11 execStateLC :: Monad m => s -> ConduitM i o (StateT s m) r -> ConduitM i o m s -- | Wrap the base monad in StateT -- -- Since 1.0.11 stateC :: (Monad m, Monad (t1 (StateT t m)), MonadTrans t1, MFunctor t1) => (t -> t1 m (b, t)) -> t1 (StateT t m) b -- | Run StateT in the base monad -- -- Since 1.0.11 runStateC :: Monad m => s -> ConduitM i o (StateT s m) r -> ConduitM i o m (r, s) -- | Evaluate StateT in the base monad -- -- Since 1.0.11 evalStateC :: Monad m => s -> ConduitM i o (StateT s m) r -> ConduitM i o m r -- | Execute StateT in the base monad -- -- Since 1.0.11 execStateC :: Monad m => s -> ConduitM i o (StateT s m) r -> ConduitM i o m s -- | Wrap the base monad in WriterT -- -- Since 1.0.11 writerLC :: (Monad m, Monad (t (WriterT w m)), MonadTrans t, Monoid w, MFunctor t) => t m (b, w) -> t (WriterT w m) b -- | Run WriterT in the base monad -- -- Since 1.0.11 runWriterLC :: (Monad m, Monoid w) => ConduitM i o (WriterT w m) r -> ConduitM i o m (r, w) -- | Execute WriterT in the base monad -- -- Since 1.0.11 execWriterLC :: (Monad m, Monoid w) => ConduitM i o (WriterT w m) r -> ConduitM i o m w -- | Wrap the base monad in WriterT -- -- Since 1.0.11 writerC :: (Monad m, Monad (t (WriterT w m)), MonadTrans t, Monoid w, MFunctor t) => t m (b, w) -> t (WriterT w m) b -- | Run WriterT in the base monad -- -- Since 1.0.11 runWriterC :: (Monad m, Monoid w) => ConduitM i o (WriterT w m) r -> ConduitM i o m (r, w) -- | Execute WriterT in the base monad -- -- Since 1.0.11 execWriterC :: (Monad m, Monoid w) => ConduitM i o (WriterT w m) r -> ConduitM i o m w -- | Wrap the base monad in RWST -- -- Since 1.0.11 rwsLC :: (Monad m, Monad (t1 (RWST t w t2 m)), MonadTrans t1, Monoid w, MFunctor t1) => (t -> t2 -> t1 m (b, t2, w)) -> t1 (RWST t w t2 m) b -- | Run RWST in the base monad -- -- Since 1.0.11 runRWSLC :: (Monad m, Monoid w) => r -> s -> ConduitM i o (RWST r w s m) res -> ConduitM i o m (res, s, w) -- | Evaluate RWST in the base monad -- -- Since 1.0.11 evalRWSLC :: (Monad m, Monoid w) => r -> s -> ConduitM i o (RWST r w s m) res -> ConduitM i o m (res, w) -- | Execute RWST in the base monad -- -- Since 1.0.11 execRWSLC :: (Monad m, Monoid w) => r -> s -> ConduitM i o (RWST r w s m) res -> ConduitM i o m (s, w) -- | Wrap the base monad in RWST -- -- Since 1.0.11 rwsC :: (Monad m, Monad (t1 (RWST t w t2 m)), MonadTrans t1, Monoid w, MFunctor t1) => (t -> t2 -> t1 m (b, t2, w)) -> t1 (RWST t w t2 m) b -- | Run RWST in the base monad -- -- Since 1.0.11 runRWSC :: (Monad m, Monoid w) => r -> s -> ConduitM i o (RWST r w s m) res -> ConduitM i o m (res, s, w) -- | Evaluate RWST in the base monad -- -- Since 1.0.11 evalRWSC :: (Monad m, Monoid w) => r -> s -> ConduitM i o (RWST r w s m) res -> ConduitM i o m (res, w) -- | Execute RWST in the base monad -- -- Since 1.0.11 execRWSC :: (Monad m, Monoid w) => r -> s -> ConduitM i o (RWST r w s m) res -> ConduitM i o m (s, w) distribute :: (Monad (t (ConduitM b o m)), Monad m, Monad (t m), MonadTrans t, MFunctor t) => ConduitM b o (t m) () -> t (ConduitM b o m) () -- | Higher-level functions to interact with the elements of a stream. Most -- of these are based on list functions. -- -- For many purposes, it's recommended to use the conduit-combinators -- library, which provides a more complete set of functions. -- -- Note that these functions all deal with individual elements of a -- stream as a sort of "black box", where there is no introspection of -- the contained elements. Values such as ByteString and -- Text will likely need to be treated specially to deal with -- their contents properly (Word8 and Char, -- respectively). See the Data.Conduit.Binary and -- Data.Conduit.Text modules. module Data.Conduit.List -- | Yield the values from the list. -- -- Subject to fusion sourceList :: Monad m => [a] -> Producer m a -- | A source that outputs no values. Note that this is just a -- type-restricted synonym for mempty. -- -- Subject to fusion -- -- Since 0.3.0 sourceNull :: Monad m => Producer m a -- | Generate a source from a seed value. -- -- Subject to fusion -- -- Since 0.4.2 unfold :: Monad m => (b -> Maybe (a, b)) -> b -> Producer m a -- | Generate a source from a seed value with a return value. -- -- Subject to fusion unfoldEither :: Monad m => (b -> Either r (a, b)) -> b -> ConduitM i a m r -- | A monadic unfold. -- -- Subject to fusion -- -- Since 1.1.2 unfoldM :: Monad m => (b -> m (Maybe (a, b))) -> b -> Producer m a -- | A monadic unfoldEither. -- -- Subject to fusion unfoldEitherM :: Monad m => (b -> m (Either r (a, b))) -> b -> ConduitM i a m r -- | Enumerate from a value to a final value, inclusive, via succ. -- -- This is generally more efficient than using Prelude's -- enumFromTo and combining with sourceList since this -- avoids any intermediate data structures. -- -- Subject to fusion -- -- Since 0.4.2 enumFromTo :: (Enum a, Ord a, Monad m) => a -> a -> Producer m a -- | Produces an infinite stream of repeated applications of f to x. -- -- Subject to fusion iterate :: Monad m => (a -> a) -> a -> Producer m a -- | Replicate a single value the given number of times. -- -- Subject to fusion -- -- Since 1.2.0 replicate :: Monad m => Int -> a -> Producer m a -- | Replicate a monadic value the given number of times. -- -- Subject to fusion -- -- Since 1.2.0 replicateM :: Monad m => Int -> m a -> Producer m a -- | A strict left fold. -- -- Subject to fusion -- -- Since 0.3.0 fold :: Monad m => (b -> a -> b) -> b -> Consumer a m b -- | A monoidal strict left fold. -- -- Subject to fusion -- -- Since 0.5.3 foldMap :: (Monad m, Monoid b) => (a -> b) -> Consumer a m b -- | Take some values from the stream and return as a list. If you want to -- instead create a conduit that pipes data to another sink, see -- isolate. This function is semantically equivalent to: -- --
--   take i = isolate i =$ consume
--   
-- -- Subject to fusion -- -- Since 0.3.0 take :: Monad m => Int -> Consumer a m [a] -- | Ignore a certain number of values in the stream. This function is -- semantically equivalent to: -- --
--   drop i = take i >> return ()
--   
-- -- However, drop is more efficient as it does not need to hold -- values in memory. -- -- Subject to fusion -- -- Since 0.3.0 drop :: Monad m => Int -> Consumer a m () -- | Take a single value from the stream, if available. -- -- Subject to fusion -- -- Since 0.3.0 head :: Monad m => Consumer a m (Maybe a) -- | Look at the next value in the stream, if available. This function will -- not change the state of the stream. -- -- Since 0.3.0 peek :: Monad m => Consumer a m (Maybe a) -- | Consume all values from the stream and return as a list. Note that -- this will pull all values into memory. -- -- Subject to fusion -- -- Since 0.3.0 consume :: Monad m => Consumer a m [a] -- | Ignore the remainder of values in the source. Particularly useful when -- combined with isolate. -- -- Subject to fusion -- -- Since 0.3.0 sinkNull :: Monad m => Consumer a m () -- | A monoidal strict left fold in a Monad. -- -- Since 1.0.8 foldMapM :: (Monad m, Monoid b) => (a -> m b) -> Consumer a m b -- | A monadic strict left fold. -- -- Subject to fusion -- -- Since 0.3.0 foldM :: Monad m => (b -> a -> m b) -> b -> Consumer a m b -- | Apply the action to all values in the stream. -- -- Subject to fusion -- -- Since 0.3.0 mapM_ :: Monad m => (a -> m ()) -> Consumer a m () -- | Apply a transformation to all values in a stream. -- -- Subject to fusion -- -- Since 0.3.0 map :: Monad m => (a -> b) -> Conduit a m b -- | Apply a transformation that may fail to all values in a stream, -- discarding the failures. -- -- Subject to fusion -- -- Since 0.5.1 mapMaybe :: Monad m => (a -> Maybe b) -> Conduit a m b -- | Generalization of mapMaybe and concatMap. It applies -- function to all values in a stream and send values inside resulting -- Foldable downstream. -- -- Subject to fusion -- -- Since 1.0.6 mapFoldable :: (Monad m, Foldable f) => (a -> f b) -> Conduit a m b -- | Filter the Just values from a stream, discarding the -- Nothing values. -- -- Subject to fusion -- -- Since 0.5.1 catMaybes :: Monad m => Conduit (Maybe a) m a -- | Generalization of catMaybes. It puts all values from -- Foldable into stream. -- -- Subject to fusion -- -- Since 1.0.6 concat :: (Monad m, Foldable f) => Conduit (f a) m a -- | Apply a transformation to all values in a stream, concatenating the -- output values. -- -- Subject to fusion -- -- Since 0.3.0 concatMap :: Monad m => (a -> [b]) -> Conduit a m b -- | concatMap with a strict accumulator. -- -- Subject to fusion -- -- Since 0.3.0 concatMapAccum :: Monad m => (a -> accum -> (accum, [b])) -> accum -> Conduit a m b -- | Deprecated synonym for mapAccum -- -- Since 1.0.6 -- | Deprecated: Use mapAccum instead scanl :: Monad m => (a -> s -> (s, b)) -> s -> Conduit a m b -- | Analog of scanl for lists. -- -- Subject to fusion -- -- Since 1.1.1 scan :: Monad m => (a -> b -> b) -> b -> ConduitM a b m b -- | Analog of mapAccumL for lists. Note that in contrast to -- mapAccumL, the function argument takes the accumulator as its -- second argument, not its first argument, and the accumulated value is -- strict. -- -- Subject to fusion -- -- Since 1.1.1 mapAccum :: Monad m => (a -> s -> (s, b)) -> s -> ConduitM a b m s -- | Group a stream into chunks of a given size. The last chunk may contain -- fewer than n elements. -- -- Subject to fusion -- -- Since 1.2.9 chunksOf :: Monad m => Int -> Conduit a m [a] -- | Grouping input according to an equality function. -- -- Subject to fusion -- -- Since 0.3.0 groupBy :: Monad m => (a -> a -> Bool) -> Conduit a m [a] -- | groupOn1 is similar to groupBy id -- -- returns a pair, indicating there are always 1 or more items in the -- grouping. This is designed to be converted into a NonEmpty structure -- but it avoids a dependency on another package -- --
--   import Data.List.NonEmpty
--   
--   groupOn1 :: (Monad m, Eq b) => (a -> b) -> Conduit a m (NonEmpty a)
--   groupOn1 f = CL.groupOn1 f =$= CL.map (uncurry (:|))
--   
-- -- Subject to fusion -- -- Since 1.1.7 groupOn1 :: (Monad m, Eq b) => (a -> b) -> Conduit a m (a, [a]) -- | Ensure that the inner sink consumes no more than the given number of -- values. Note this this does not ensure that the sink consumes -- all of those values. To get the latter behavior, combine with -- sinkNull, e.g.: -- --
--   src $$ do
--       x <- isolate count =$ do
--           x <- someSink
--           sinkNull
--           return x
--       someOtherSink
--       ...
--   
-- -- Subject to fusion -- -- Since 0.3.0 isolate :: Monad m => Int -> Conduit a m a -- | Keep only values in the stream passing a given predicate. -- -- Subject to fusion -- -- Since 0.3.0 filter :: Monad m => (a -> Bool) -> Conduit a m a -- | Apply a monadic transformation to all values in a stream. -- -- If you do not need the transformed values, and instead just want the -- monadic side-effects of running the action, see mapM_. -- -- Subject to fusion -- -- Since 0.3.0 mapM :: Monad m => (a -> m b) -> Conduit a m b -- | Apply a monadic action on all values in a stream. -- -- This Conduit can be used to perform a monadic side-effect for -- every value, whilst passing the value through the Conduit -- as-is. -- --
--   iterM f = mapM (\a -> f a >>= \() -> return a)
--   
-- -- Subject to fusion -- -- Since 0.5.6 iterM :: Monad m => (a -> m ()) -> Conduit a m a -- | Deprecated synonym for mapAccumM -- -- Since 1.0.6 -- | Deprecated: Use mapAccumM instead scanlM :: Monad m => (a -> s -> m (s, b)) -> s -> Conduit a m b -- | Monadic scanl. -- -- Subject to fusion -- -- Since 1.1.1 scanM :: Monad m => (a -> b -> m b) -> b -> ConduitM a b m b -- | Monadic mapAccum. -- -- Subject to fusion -- -- Since 1.1.1 mapAccumM :: Monad m => (a -> s -> m (s, b)) -> s -> ConduitM a b m s -- | Apply a monadic transformation that may fail to all values in a -- stream, discarding the failures. -- -- Subject to fusion -- -- Since 0.5.1 mapMaybeM :: Monad m => (a -> m (Maybe b)) -> Conduit a m b -- | Monadic variant of mapFoldable. -- -- Subject to fusion -- -- Since 1.0.6 mapFoldableM :: (Monad m, Foldable f) => (a -> m (f b)) -> Conduit a m b -- | Apply a monadic transformation to all values in a stream, -- concatenating the output values. -- -- Subject to fusion -- -- Since 0.3.0 concatMapM :: Monad m => (a -> m [b]) -> Conduit a m b -- | concatMapM with a strict accumulator. -- -- Subject to fusion -- -- Since 0.3.0 concatMapAccumM :: Monad m => (a -> accum -> m (accum, [b])) -> accum -> Conduit a m b -- | Run a Pipe repeatedly, and output its result value -- downstream. Stops when no more input is available from upstream. -- -- Since 0.5.0 sequence :: Monad m => Consumer i m o -> Conduit i m o