-- 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, and fits in the same general solution -- space as enumerator/iteratee and pipes. For -- a brief tutorial, please see the Data.Conduit module. -- -- Release history: -- -- @package conduit @version 0.5.2 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 -- | Provides a stream of output values, without consuming any input or -- producing a final result. -- -- Since 0.5.0 type Source m o = Pipe () () o () m () -- | Generalized Source. -- -- Since 0.5.0 type GSource m o = forall l i u. Pipe l i o u m () -- | Consumes a stream of input values and produces a final result, without -- producing any output. -- -- Since 0.5.0 type Sink i m r = Pipe i i Void () m r -- | Generalized Sink without leftovers. -- -- Since 0.5.0 type GSink i m r = forall l o u. Pipe l i o u m r -- | Generalized Sink with leftovers. -- -- Since 0.5.0 type GLSink i m r = forall o u. Pipe i i o u m r -- | Generalized Sink without leftovers returning upstream result. -- -- Since 0.5.0 type GInfSink i m = forall l o r. Pipe l i o r m r -- | Generalized Sink with leftovers returning upstream result. -- -- Since 0.5.0 type GLInfSink i m = forall o r. Pipe i i o r 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 = Pipe i i o () m () -- | Generalized conduit without leftovers. -- -- Since 0.5.0 type GConduit i m o = forall l u. Pipe l i o u m () -- | Generalized conduit with leftovers. -- -- Since 0.5.0 type GLConduit i m o = forall u. Pipe i i o u m () -- | Generalized conduit without leftovers returning upstream result. -- -- Since 0.5.0 type GInfConduit i m o = forall l r. Pipe l i o r m r -- | Generalized conduit with leftovers returning upstream result. -- -- Since 0.5.0 type GLInfConduit i m o = forall r. Pipe i i o r m r -- | 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 :: (Source m o) -> (m ()) -> ResumableSource m o -- | Wait for a single input value from upstream, terminating immediately -- if no data is available. -- -- 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 () -- | 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 () -- | Perform some allocation and run an inner Pipe. 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 -- | 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) -- | 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 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 () -- | Transform the monad that a Pipe lives in. -- -- 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) -- | 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 ()) instance Monad m => Monoid (Pipe l i o u m ()) instance MonadIO m => MonadIO (Pipe l i o u m) instance MonadTrans (Pipe l i o u) instance MonadBase base m => MonadBase base (Pipe l i o u m) instance Monad m => Monad (Pipe l i o u m) instance Monad m => Applicative (Pipe l i o u m) instance Monad m => Functor (Pipe l i o u m) -- | Utility functions from older versions of conduit. These -- should be considered deprecated, as there are now easier ways to -- handle their use cases. This module is provided solely for backwards -- compatibility. module Data.Conduit.Util -- | Construct a Source with some stateful functions. This function -- addresses threading the state value for you. -- -- Since 0.3.0 sourceState :: Monad m => state -> (state -> m (SourceStateResult state output)) -> Source m output -- | A combination of sourceIO and sourceState. -- -- Since 0.3.0 sourceStateIO :: MonadResource m => IO state -> (state -> IO ()) -> (state -> m (SourceStateResult state output)) -> Source m output -- | The return value when pulling in the sourceState function. -- Either indicates no more data, or the next value and an updated state. -- -- Since 0.3.0 data SourceStateResult state output StateOpen :: state -> output -> SourceStateResult state output StateClosed :: SourceStateResult state output -- | Construct a Source based on some IO actions for alloc/release. -- -- Since 0.3.0 sourceIO :: MonadResource m => IO state -> (state -> IO ()) -> (state -> m (SourceIOResult output)) -> Source m output -- | The return value when pulling in the sourceIO function. -- Either indicates no more data, or the next value. -- -- Since 0.3.0 data SourceIOResult output IOOpen :: output -> SourceIOResult output IOClosed :: SourceIOResult output -- | Construct a Sink with some stateful functions. This function -- addresses threading the state value for you. -- -- Since 0.3.0 sinkState :: Monad m => state -> (state -> input -> m (SinkStateResult state input output)) -> (state -> m output) -> Sink input m output -- | A helper type for sinkState, indicating the result of being -- pushed to. It can either indicate that processing is done, or to -- continue with the updated state. -- -- Since 0.3.0 data SinkStateResult state input output StateDone :: (Maybe input) -> output -> SinkStateResult state input output StateProcessing :: state -> SinkStateResult state input output -- | Construct a Sink. Note that your push and close functions need -- not explicitly perform any cleanup. -- -- Since 0.3.0 sinkIO :: MonadResource m => IO state -> (state -> IO ()) -> (state -> input -> m (SinkIOResult input output)) -> (state -> m output) -> Sink input m output -- | A helper type for sinkIO, indicating the result of being -- pushed to. It can either indicate that processing is done, or to -- continue. -- -- Since 0.3.0 data SinkIOResult input output IODone :: (Maybe input) -> output -> SinkIOResult input output IOProcessing :: SinkIOResult input output -- | A helper function for returning a list of values from a -- Conduit. -- -- Since 0.3.0 haveMore :: Conduit a m b -> m () -> [b] -> Conduit a m b -- | Construct a Conduit with some stateful functions. This function -- addresses threading the state value for you. -- -- Since 0.3.0 conduitState :: Monad m => state -> (state -> input -> m (ConduitStateResult state input output)) -> (state -> m [output]) -> Conduit input m output -- | A helper type for conduitState, indicating the result of -- being pushed to. It can either indicate that processing is done, or to -- continue with the updated state. -- -- Since 0.3.0 data ConduitStateResult state input output StateFinished :: (Maybe input) -> [output] -> ConduitStateResult state input output StateProducing :: state -> [output] -> ConduitStateResult state input output -- | Construct a Conduit. -- -- Since 0.3.0 conduitIO :: MonadResource m => IO state -> (state -> IO ()) -> (state -> input -> m (ConduitIOResult input output)) -> (state -> m [output]) -> Conduit input m output -- | A helper type for conduitIO, indicating the result of being -- pushed to. It can either indicate that processing is done, or to -- continue. -- -- Since 0.3.0 data ConduitIOResult input output IOFinished :: (Maybe input) -> [output] -> ConduitIOResult input output IOProducing :: [output] -> ConduitIOResult input output -- | Helper type for constructing a Conduit based on -- Sinks. This allows you to write higher-level code that takes -- advantage of existing conduits and sinks, and leverages a sink's -- monadic interface. -- -- Since 0.3.0 type SequencedSink state input m output = state -> Sink input m (SequencedSinkResponse state input m output) -- | Convert a SequencedSink into a Conduit. -- -- Since 0.3.0 sequenceSink :: Monad m => state -> SequencedSink state input m output -> Conduit input m output -- | Return value from a SequencedSink. -- -- Since 0.3.0 data SequencedSinkResponse state input m output -- | Set a new state, and emit some new output. Emit :: state -> [output] -> SequencedSinkResponse state input m output -- | End the conduit. Stop :: SequencedSinkResponse state input m output -- | Pass control to a new conduit. StartConduit :: (Conduit input m output) -> SequencedSinkResponse state input m output -- | Combines two sources. The new source will stop producing once either -- source has been exhausted. -- -- Since 0.3.0 zip :: Monad m => Source m a -> Source m b -> Source m (a, b) -- | 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') 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 = Pipe () () 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 = Pipe i i o () m () -- | Consumes a stream of input values and produces a final result, without -- producing any output. -- -- Since 0.5.0 type Sink i m r = Pipe i i Void () m r -- | The connect operator, which pulls data from a source and pushes to a -- sink. When either side closes, the other side will immediately be -- closed as well. If you would like to keep the Source open to -- be used for another operations, use the connect-and-resume operator -- $$+. -- -- Since 0.4.0 ($$) :: Monad m => Source m a -> Sink a m b -> m b -- | Left fuse, combining a source and a conduit together into a new -- source. -- -- Both the Source and Conduit will be closed when the -- newly-created Source is closed. -- -- Leftover data from the Conduit will be discarded. -- -- Since 0.4.0 ($=) :: Monad m => Source m a -> Conduit a m b -> Source m b -- | Right fuse, combining a conduit and a sink together into a new sink. -- -- Both the Conduit and Sink will be closed when the -- newly-created Sink is closed. -- -- Leftover data returned from the Sink will be discarded. -- -- Since 0.4.0 (=$) :: Monad m => Conduit a m b -> Sink b m c -> Sink a m c -- | 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 -> Conduit b m c -> Conduit a m c -- | 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 -- | 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. For example: -- --
--   >>> :load Data.Conduit.List
--   
--   >>> :set -XNoMonomorphismRestriction
--   
--   >>> let pipe = peek >>= \x -> fold (Prelude.+) 0 >>= \y -> return (x, y)
--   
--   >>> runPipe $ sourceList [1..10] >+> injectLeftovers pipe
--   (Just 1,55)
--   
-- -- 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 -- | 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 -- | 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 -- | Wait for a single input value from upstream, terminating immediately -- if no data is available. -- -- 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 () -- | 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 () -- | Perform some allocation and run an inner Pipe. 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 -- | 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 -- | 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) -- | Continue processing after usage of $$+. -- -- Since 0.5.0 ($$++) :: Monad m => ResumableSource m a -> Sink a m b -> m (ResumableSource m a, b) -- | 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 -- | 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 ()) -- | Transform the monad that a Pipe lives in. -- -- 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 -- | 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) -- | Generalized Source. -- -- Since 0.5.0 type GSource m o = forall l i u. Pipe l i o u m () -- | Generalized Sink without leftovers. -- -- Since 0.5.0 type GSink i m r = forall l o u. Pipe l i o u m r -- | Generalized Sink with leftovers. -- -- Since 0.5.0 type GLSink i m r = forall o u. Pipe i i o u m r -- | Generalized Sink without leftovers returning upstream result. -- -- Since 0.5.0 type GInfSink i m = forall l o r. Pipe l i o r m r -- | Generalized Sink with leftovers returning upstream result. -- -- Since 0.5.0 type GLInfSink i m = forall o r. Pipe i i o r m r -- | Generalized conduit without leftovers. -- -- Since 0.5.0 type GConduit i m o = forall l u. Pipe l i o u m () -- | Generalized conduit with leftovers. -- -- Since 0.5.0 type GLConduit i m o = forall u. Pipe i i o u m () -- | Generalized conduit without leftovers returning upstream result. -- -- Since 0.5.0 type GInfConduit i m o = forall l r. Pipe l i o r m r -- | Generalized conduit with leftovers returning upstream result. -- -- Since 0.5.0 type GLInfConduit i m o = forall r. Pipe i i o r m r -- | 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 -- | The Resource transformer. This transformer keeps track of all -- registered actions, and calls them upon exit (via -- runResourceT). Actions may be registered via register, -- or resources may be allocated atomically via allocate. -- allocate corresponds closely to bracket. -- -- Releasing may be performed before exit via the release -- function. This is a highly recommended optimization, as it will ensure -- that scarce resources are freed early. Note that calling -- release will deregister the action, so that a release action -- will only ever be called once. -- -- Since 0.3.0 data ResourceT (m :: * -> *) a :: (* -> *) -> * -> * -- | A Monad which allows for safe resource allocation. In theory, -- any monad transformer stack included a ResourceT can be an -- instance of MonadResource. -- -- Note: runResourceT has a requirement for a -- MonadBaseControl IO m monad, which allows control operations -- to be lifted. A MonadResource does not have this requirement. -- This means that transformers such as ContT can be an instance -- of MonadResource. However, the ContT wrapper will -- need to be unwrapped before calling runResourceT. -- -- Since 0.3.0 class (MonadThrow m, MonadUnsafeIO m, MonadIO m, Applicative m) => MonadResource (m :: * -> *) -- | A Monad which can throw exceptions. Note that this does not -- work in a vanilla ST or Identity monad. Instead, you -- should use the ExceptionT transformer in your stack if you are -- dealing with a non-IO base monad. -- -- Since 0.3.0 class Monad m => MonadThrow (m :: * -> *) monadThrow :: (MonadThrow m, Exception e) => e -> m a -- | A Monad based on some monad which allows running of some -- IO actions, via unsafe calls. This applies to IO and -- ST, for instance. -- -- Since 0.3.0 class Monad m => MonadUnsafeIO (m :: * -> *) unsafeLiftIO :: MonadUnsafeIO m => IO a -> m a -- | Unwrap a ResourceT transformer, and call all registered release -- actions. -- -- Note that there is some reference counting involved due to -- resourceForkIO. If multiple threads are sharing the same -- collection of resources, only the last call to runResourceT -- will deallocate the resources. -- -- Since 0.3.0 runResourceT :: MonadBaseControl IO m => ResourceT m a -> m a instance Show a => Show (Flush a) instance Eq a => Eq (Flush a) instance Ord a => Ord (Flush a) instance Functor Flush -- | Higher-level functions to interact with the elements of a stream. Most -- of these are based on list 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 -- | Convert a list into a source. -- -- Since 0.3.0 sourceList :: Monad m => [a] -> Pipe l i a u m () -- | A source that outputs no values. Note that this is just a -- type-restricted synonym for mempty. -- -- Since 0.3.0 sourceNull :: Monad m => GSource m a -- | Generate a source from a seed value. -- -- Since 0.4.2 unfold :: Monad m => (b -> Maybe (a, b)) -> b -> GSource m a -- | 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. -- -- Since 0.4.2 enumFromTo :: (Enum a, Eq a, Monad m) => a -> a -> GSource m a -- | Produces an infinite stream of repeated applications of f to x. iterate :: Monad m => (a -> a) -> a -> GSource m a -- | A strict left fold. -- -- Since 0.3.0 fold :: Monad m => (b -> a -> b) -> b -> GSink 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
--   
-- -- Since 0.3.0 take :: Monad m => Int -> GSink 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. -- -- Since 0.3.0 drop :: Monad m => Int -> GSink a m () -- | Take a single value from the stream, if available. -- -- Since 0.3.0 head :: Monad m => GSink 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 => GLSink a m (Maybe a) -- | Consume all values from the stream and return as a list. Note that -- this will pull all values into memory. For a lazy variant, see -- Data.Conduit.Lazy. -- -- Since 0.3.0 consume :: Monad m => GSink a m [a] -- | Ignore the remainder of values in the source. Particularly useful when -- combined with isolate. -- -- Since 0.3.0 sinkNull :: Monad m => GInfSink a m -- | A monadic strict left fold. -- -- Since 0.3.0 foldM :: Monad m => (b -> a -> m b) -> b -> GSink a m b -- | Apply the action to all values in the stream. -- -- Since 0.3.0 mapM_ :: Monad m => (a -> m ()) -> GInfSink a m -- | Apply a transformation to all values in a stream. -- -- Since 0.3.0 map :: Monad m => (a -> b) -> GInfConduit a m b -- | Apply a transformation that may fail to all values in a stream, -- discarding the failures. -- -- Since 0.5.1 mapMaybe :: Monad m => (a -> Maybe b) -> GInfConduit a m b -- | Filter the Just values from a stream, discarding the -- Nothing values. -- -- Since 0.5.1 catMaybes :: Monad m => GInfConduit (Maybe a) m a -- | Apply a transformation to all values in a stream, concatenating the -- output values. -- -- Since 0.3.0 concatMap :: Monad m => (a -> [b]) -> GInfConduit a m b -- | concatMap with an accumulator. -- -- Since 0.3.0 concatMapAccum :: Monad m => (a -> accum -> (accum, [b])) -> accum -> GInfConduit a m b -- | Grouping input according to an equality function. -- -- Since 0.3.0 groupBy :: Monad m => (a -> a -> Bool) -> GInfConduit a m [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
--       ...
--   
-- -- Since 0.3.0 isolate :: Monad m => Int -> GConduit a m a -- | Keep only values in the stream passing a given predicate. -- -- Since 0.3.0 filter :: Monad m => (a -> Bool) -> GInfConduit 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_. -- -- Since 0.3.0 mapM :: Monad m => (a -> m b) -> GInfConduit a m b -- | Apply a monadic transformation that may fail to all values in a -- stream, discarding the failures. -- -- Since 0.5.1 mapMaybeM :: Monad m => (a -> m (Maybe b)) -> GInfConduit a m b -- | Apply a monadic transformation to all values in a stream, -- concatenating the output values. -- -- Since 0.3.0 concatMapM :: Monad m => (a -> m [b]) -> GInfConduit a m b -- | concatMapM with an accumulator. -- -- Since 0.3.0 concatMapAccumM :: Monad m => (a -> accum -> m (accum, [b])) -> accum -> GInfConduit 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 => GLSink i m o -> GLInfConduit i m o -- | Functions for interacting with bytes. module Data.Conduit.Binary -- | Stream the contents of a file as binary data. -- -- Since 0.3.0 sourceFile :: MonadResource m => FilePath -> GSource m ByteString -- | Stream the contents of a Handle as binary data. Note that this -- function will not automatically close the Handle when -- processing completes, since it did not acquire the Handle in -- the first place. -- -- Since 0.3.0 sourceHandle :: MonadIO m => Handle -> GSource m ByteString -- | An alternative to sourceHandle. Instead of taking a pre-opened -- Handle, it takes an action that opens a Handle (in read -- mode), so that it can open it only when needed and closed it as soon -- as possible. -- -- Since 0.3.0 sourceIOHandle :: MonadResource m => IO Handle -> GSource m ByteString -- | Stream the contents of a file as binary data, starting from a certain -- offset and only consuming up to a certain number of bytes. -- -- Since 0.3.0 sourceFileRange :: MonadResource m => FilePath -> Maybe Integer -> Maybe Integer -> GSource m ByteString -- | Stream all incoming data to the given file. -- -- Since 0.3.0 sinkFile :: MonadResource m => FilePath -> GInfSink ByteString m -- | Stream all incoming data to the given Handle. Note that this -- function will not automatically close the Handle when -- processing completes. -- -- Since 0.3.0 sinkHandle :: MonadIO m => Handle -> GInfSink ByteString m -- | An alternative to sinkHandle. Instead of taking a pre-opened -- Handle, it takes an action that opens a Handle (in write -- mode), so that it can open it only when needed and close it as soon as -- possible. -- -- Since 0.3.0 sinkIOHandle :: MonadResource m => IO Handle -> GInfSink ByteString m -- | Stream the contents of the input to a file, and also send it along the -- pipeline. Similar in concept to the Unix command tee. -- -- Since 0.3.0 conduitFile :: MonadResource m => FilePath -> GInfConduit ByteString m ByteString -- | Stream the chunks from a lazy bytestring. -- -- Since 0.5.0 sourceLbs :: Monad m => ByteString -> GSource m ByteString -- | Return the next byte from the stream, if available. -- -- Since 0.3.0 head :: Monad m => GLSink ByteString m (Maybe Word8) -- | Ignore all bytes while the predicate returns True. -- -- Since 0.3.0 dropWhile :: Monad m => (Word8 -> Bool) -> GLSink ByteString m () -- | Take the given number of bytes, if available. -- -- Since 0.3.0 take :: Monad m => Int -> GLSink ByteString m ByteString -- | Drop up to the given number of bytes. -- -- Since 0.5.0 drop :: Monad m => Int -> GLSink ByteString m () -- | Ensure that only up to the given number of bytes are consume by the -- inner sink. Note that this does not ensure that all of those -- bytes are in fact consumed. -- -- Since 0.3.0 isolate :: Monad m => Int -> GLConduit ByteString m ByteString -- | Return all bytes while the predicate returns True. -- -- Since 0.3.0 takeWhile :: Monad m => (Word8 -> Bool) -> GLConduit ByteString m ByteString -- | Split the input bytes into lines. In other words, split on the LF byte -- (10), and strip it from the output. -- -- Since 0.3.0 lines :: Monad m => GInfConduit ByteString m ByteString -- | Handle streams of text. -- -- Parts of this code were taken from enumerator and adapted for -- conduits. module Data.Conduit.Text -- | A specific character encoding. -- -- Since 0.3.0 data Codec -- | Convert text into bytes, using the provided codec. If the codec is not -- capable of representing an input character, an exception will be -- thrown. -- -- Since 0.3.0 encode :: MonadThrow m => Codec -> GInfConduit Text m ByteString -- | Convert bytes into text, using the provided codec. If the codec is not -- capable of decoding an input byte sequence, an exception will be -- thrown. -- -- Since 0.3.0 decode :: MonadThrow m => Codec -> GInfConduit ByteString m Text -- | Since 0.3.0 utf8 :: Codec -- | Since 0.3.0 utf16_le :: Codec -- | Since 0.3.0 utf16_be :: Codec -- | Since 0.3.0 utf32_le :: Codec -- | Since 0.3.0 utf32_be :: Codec -- | Since 0.3.0 ascii :: Codec -- | Since 0.3.0 iso8859_1 :: Codec -- | Emit each line separately -- -- Since 0.4.1 lines :: Monad m => GInfConduit Text m Text instance Typeable TextException instance Show TextException instance Exception TextException instance Show Codec -- | Use lazy I/O for consuming the contents of a source. Warning: All -- normal warnings of lazy I/O apply. In particular, if you are using -- this with a ResourceT transformer, you must force the list to -- be evaluated before exiting the ResourceT. module Data.Conduit.Lazy -- | Use lazy I/O to consume all elements from a Source. -- -- This function relies on monadActive to determine if the -- underlying monadic state has been closed. -- -- Since 0.3.0 lazyConsume :: (MonadBaseControl IO m, MonadActive m) => Pipe l i a () m r -> m [a]