-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A pull-based approach to streaming data. -- -- Conduits are an approach to the streaming data problem. It is meant as -- an alternative to enumerators/iterators, hoping to address the same -- issues with different trade-offs based on real-world experience with -- enumerators. For more information, see -- http://www.yesodweb.com/blog/2011/12/conduits. @package conduit @version 0.0.2 -- | Allocate resources which are guaranteed to be released. -- -- For more information, see -- http://www.yesodweb.com/blog/2011/12/resourcet. -- -- One point to note: all register cleanup actions live in the base -- monad, not the main monad. This allows both more efficient code, and -- for monads to be transformed. module Control.Monad.Trans.Resource -- | 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 with or -- withIO. The with functions correspond 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. data ResourceT m a -- | A lookup key for a specific release action. This value is returned by -- register, with and withIO, and is passed to -- release. data ReleaseKey -- | 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. runResourceT :: Resource m => ResourceT m a -> m a -- | Perform some allocation, and automatically register a cleanup action. -- -- If you are performing an IO action, it will likely be easier -- to use the withIO function, which handles types more cleanly. with :: Resource m => Base m a -> (a -> Base m ()) -> ResourceT m (ReleaseKey, a) -- | Same as with, but explicitly uses IO as a base. withIO :: ResourceIO m => IO a -> (a -> IO ()) -> ResourceT m (ReleaseKey, a) -- | Register some action that will be called precisely once, either when -- runResourceT is called, or when the ReleaseKey is passed -- to release. register :: Resource m => Base m () -> ResourceT m ReleaseKey -- | Call a release action early, and deregister it from the list of -- cleanup actions to be performed. release :: Resource m => ReleaseKey -> ResourceT m () -- | Modify a value in a reference. Note that, in the case of IO -- stacks, this is an atomic action. modifyRef :: Resource m => Ref (Base m) a -> (a -> (a, b)) -> ResourceT m b -- | Read a value from a reference. readRef :: Resource m => Ref (Base m) a -> ResourceT m a -- | Write a value to a reference. writeRef :: Resource m => Ref (Base m) a -> a -> ResourceT m () -- | Create a new reference. newRef :: Resource m => a -> ResourceT m (Ref (Base m) a) -- | Introduce a reference-counting scheme to allow a resource context to -- be shared by multiple threads. Once the last thread exits, all -- remaining resources will be released. -- -- Note that abuse of this function will greatly delay the deallocation -- of registered resources. This function should be used with care. A -- general guideline: -- -- If you are allocating a resource that should be shared by multiple -- threads, and will be held for a long time, you should allocate it at -- the beginning of a new ResourceT block and then call -- resourceForkIO from there. resourceForkIO :: ResourceIO m => ResourceT m () -> ResourceT m ThreadId -- | Transform the monad a ResourceT lives in. This is most often -- used to strip or add new transformers to a stack, e.g. to run a -- ReaderT. Note that the original and new monad must both have -- the same Base monad. transResourceT :: (Base m) ~ (Base n) => (m a -> n a) -> ResourceT m a -> ResourceT n a -- | The express purpose of this transformer is to allow the ST -- monad to catch exceptions via the ResourceThrow typeclass. newtype ExceptionT m a ExceptionT :: m (Either SomeException a) -> ExceptionT m a runExceptionT :: ExceptionT m a -> m (Either SomeException a) -- | Same as runExceptionT, but immediately throw any -- exception returned. runExceptionT_ :: Monad m => ExceptionT m a -> m a -- | A Monad with a base that has mutable references, and allows -- some way to run base actions and clean up properly. class (HasRef (Base m), Monad m) => Resource m where { type family Base m :: * -> *; } resourceLiftBase :: Resource m => Base m a -> m a resourceBracket_ :: Resource m => Base m () -> Base m () -> m c -> m c -- | A Resource based on some monad which allows running of some -- IO actions, via unsafe calls. This applies to IO and -- ST, for instance. class Resource m => ResourceUnsafeIO m unsafeFromIO :: ResourceUnsafeIO m => IO a -> m a -- | A Resource which can safely run IO calls. class (ResourceBaseIO (Base m), ResourceUnsafeIO m, ResourceThrow m, MonadIO m, MonadBaseControl IO m) => ResourceIO m -- | A helper class for ResourceIO, stating that the base monad -- provides IO actions. class ResourceBaseIO m safeFromIOBase :: ResourceBaseIO m => IO a -> m a -- | A Resource which can throw exceptions. Note that this does not -- work in a vanilla ST monad. Instead, you should use the -- ExceptionT transformer on top of ST. class Resource m => ResourceThrow m resourceThrow :: (ResourceThrow m, Exception e) => e -> m a -- | A base monad which provides mutable references and some exception-safe -- way of interacting with them. For monads which cannot handle -- exceptions (e.g., ST), exceptions may be ignored. However, in -- such cases, scarce resources should not be allocated in those -- monads, as exceptions may cause the cleanup functions to not run. -- -- The instance for IO, however, is fully exception-safe. -- -- Minimal complete definition: Ref, newRef', -- readRef' and writeRef'. class Monad m => HasRef m where { type family Ref m :: * -> *; { modifyRef' sa f = do { a0 <- readRef' sa; let (a, b) = f a0; writeRef' sa a; return b } mask f = f id mask_ = mask . const try = liftM Right } } newRef' :: HasRef m => a -> m (Ref m a) readRef' :: HasRef m => Ref m a -> m a writeRef' :: HasRef m => Ref m a -> a -> m () modifyRef' :: HasRef m => Ref m a -> (a -> (a, b)) -> m b mask :: HasRef m => ((forall a. m a -> m a) -> m b) -> m b mask_ :: HasRef m => m a -> m a try :: HasRef m => m a -> m (Either SomeException a) instance Typeable ReleaseKey instance (Monoid w, ResourceThrow m) => ResourceThrow (WriterT w m) instance ResourceThrow m => ResourceThrow (StateT s m) instance (Monoid w, ResourceThrow m) => ResourceThrow (RWST r w s m) instance (Monoid w, ResourceThrow m) => ResourceThrow (RWST r w s m) instance (Monoid w, ResourceThrow m) => ResourceThrow (WriterT w m) instance ResourceThrow m => ResourceThrow (StateT s m) instance ResourceThrow m => ResourceThrow (ReaderT r m) instance (Error e, ResourceThrow m) => ResourceThrow (ErrorT e m) instance ResourceThrow m => ResourceThrow (MaybeT m) instance ResourceThrow m => ResourceThrow (ListT m) instance ResourceThrow m => ResourceThrow (IdentityT m) instance ResourceThrow IO instance (Resource m, MonadBaseControl (Base m) m) => ResourceThrow (ExceptionT m) instance MonadBaseControl b m => MonadBaseControl b (ExceptionT m) instance MonadTransControl ExceptionT instance MonadTrans ExceptionT instance MonadBase b m => MonadBase b (ExceptionT m) instance Monad m => Monad (ExceptionT m) instance Monad m => Applicative (ExceptionT m) instance Monad m => Functor (ExceptionT m) instance MonadBaseControl b m => MonadBaseControl b (ResourceT m) instance MonadBase b m => MonadBase b (ResourceT m) instance MonadIO m => MonadIO (ResourceT m) instance MonadTrans ResourceT instance Monad m => Monad (ResourceT m) instance Monad m => Applicative (ResourceT m) instance Monad m => Functor (ResourceT m) instance Typeable1 m => Typeable1 (ResourceT m) instance (MonadTransControl t, ResourceIO m, Monad (t m), ResourceThrow (t m), MonadBaseControl IO (t m), MonadIO (t m)) => ResourceIO (t m) instance ResourceIO IO instance ResourceBaseIO IO instance (MonadTransControl t, ResourceUnsafeIO m, Monad (t m)) => ResourceUnsafeIO (t m) instance ResourceUnsafeIO (ST s) instance ResourceUnsafeIO (ST s) instance ResourceUnsafeIO IO instance (MonadTransControl t, Resource m, Monad (t m)) => Resource (t m) instance Resource (ST s) instance Resource (ST s) instance Resource IO instance HasRef (ST s) instance HasRef (ST s) instance HasRef IO -- | The main module, exporting types, utility functions, and fuse and -- connect operators. module Data.Conduit -- | Result of pulling from a source. Either a new piece of data -- (Open), or indicates that the source is now Closed. -- -- Since 0.0.0 data SourceResult a Open :: a -> SourceResult a Closed :: SourceResult a -- | A PreparedSource has two operations on it: pull some data, and -- close the PreparedSource. Since PreparedSource is built -- on top of ResourceT, all acquired resources should be -- automatically released anyway. Closing a PreparedSource early -- is merely an optimization to free scarce resources as soon as -- possible. -- -- A PreparedSource has three invariants: -- -- -- -- Since 0.0.0 data PreparedSource m a PreparedSource :: ResourceT m (SourceResult a) -> ResourceT m () -> PreparedSource m a sourcePull :: PreparedSource m a -> ResourceT m (SourceResult a) sourceClose :: PreparedSource m a -> ResourceT m () -- | All but the simplest of PreparedSources (e.g., repeat) -- require some type of state to track their current status. This may be -- in the form of a mutable variable (e.g., IORef), or via -- opening a resource like a Handle. While a -- PreparedSource is given no opportunity to acquire such -- resources, this type is. -- -- A Source is simply a monadic action that returns a -- PreparedSource. One nice consequence of this is the possibility -- of creating an efficient Monoid instance, which will only -- acquire one resource at a time, instead of bulk acquiring all -- resources at the beginning of running the Source. -- -- Note that each time you "call" a Source, it is started from -- scratch. If you want a resumable source (e.g., one which can be passed -- to multiple Sinks), you likely want to use a -- BufferedSource. -- -- Since 0.0.0 newtype Source m a Source :: ResourceT m (PreparedSource m a) -> Source m a prepareSource :: Source m a -> ResourceT m (PreparedSource m a) -- | When actually interacting with Sources, we usually want to be -- able to buffer the output, in case any intermediate steps return -- leftover data. A BufferedSource allows for such buffering, via -- the bsourceUnpull function. -- -- A BufferedSource, unlike a Source, is resumable, meaning -- it can be passed to multiple Sinks without restarting. -- -- Finally, a BufferedSource relaxes one of the invariants of a -- Source: calling bsourcePull after an EOF will -- simply return another EOF. -- -- A BufferedSource is also known as a resumable source, -- in that it can be called multiple times, and each time will provide -- new data. One caveat: while the types will allow you to use the -- buffered source in multiple threads, there is no guarantee that all -- BufferedSources will handle this correctly. -- -- Since 0.0.0 data BufferedSource m a BufferedSource :: ResourceT m (SourceResult a) -> (a -> ResourceT m ()) -> ResourceT m () -> BufferedSource m a bsourcePull :: BufferedSource m a -> ResourceT m (SourceResult a) bsourceUnpull :: BufferedSource m a -> a -> ResourceT m () bsourceClose :: BufferedSource m a -> ResourceT m () -- | Since 0.0.0 data SourceInvariantException PullAfterEOF :: String -> SourceInvariantException -- | This typeclass allows us to unify operators on Source and -- BufferedSource. -- -- Since 0.0.0 class BufferSource s bufferSource :: (BufferSource s, Resource m) => s m a -> ResourceT m (BufferedSource m a) -- | Turn a BufferedSource into a Source. Note that in -- general this will mean your original BufferedSource will be -- closed. Additionally, all leftover data from usage of the returned -- Source will be discarded. In other words: this is a -- no-going-back move. -- -- Note: bufferSource . unbufferSource is not -- the identity function. -- -- Since 0.0.1 unbufferSource :: Monad m => BufferedSource m a -> Source m a -- | A Sink ultimately returns a single output value. Each time -- data is pushed to it, a Sink may indicate that it is still -- processing data, or that it is done, in which case it returns some -- optional leftover input and an output value. -- -- Since 0.0.0 data SinkResult input output Processing :: SinkResult input output Done :: (Maybe input) -> output -> SinkResult input output -- | In general, a sink will consume data and eventually produce an output -- when it has consumed "enough" data. There are two caveats to that -- statement: -- -- -- -- To allow for the first caveat, we have the SinkNoData -- constructor. For the second, the SinkData constructor has two -- records: one for receiving more input, and the other to indicate the -- end of a stream. Note that, at the end of a stream, some output is -- required. If a specific Sink implementation cannot always -- produce output, this should be indicated in its return value, using -- something like a Maybe or Either. -- -- Invariants: -- -- -- -- Since 0.0.0 data PreparedSink input m output SinkNoData :: output -> PreparedSink input m output SinkData :: (input -> ResourceT m (SinkResult input output)) -> ResourceT m output -> PreparedSink input m output sinkPush :: PreparedSink input m output -> input -> ResourceT m (SinkResult input output) sinkClose :: PreparedSink input m output -> ResourceT m output -- | Most PreparedSinks require some type of state, similar to -- PreparedSources. Like a Source for a -- PreparedSource, a Sink is a simple monadic wrapper -- around a PreparedSink which allows initialization of such -- state. See Source for further caveats. -- -- Note that this type provides a Monad instance, allowing you to -- easily compose Sinks together. -- -- Since 0.0.0 newtype Sink input m output Sink :: ResourceT m (PreparedSink input m output) -> Sink input m output prepareSink :: Sink input m output -> ResourceT m (PreparedSink input m output) -- | When data is pushed to a Conduit, it may either indicate that -- it is still producing output and provide some, or indicate that it is -- finished producing output, in which case it returns optional leftover -- input and some final output. -- -- Since 0.0.0 data ConduitResult input output Producing :: [output] -> ConduitResult input output Finished :: (Maybe input) -> [output] -> ConduitResult input output -- | A conduit has two operations: it can receive new input (a push), and -- can be closed. -- -- Invariants: -- -- -- -- Since 0.0.0 data PreparedConduit input m output PreparedConduit :: (input -> ResourceT m (ConduitResult input output)) -> ResourceT m [output] -> PreparedConduit input m output conduitPush :: PreparedConduit input m output -> input -> ResourceT m (ConduitResult input output) conduitClose :: PreparedConduit input m output -> ResourceT m [output] -- | A monadic action generating a PreparedConduit. See -- Source and Sink for more motivation. -- -- Since 0.0.0 newtype Conduit input m output Conduit :: ResourceT m (PreparedConduit input m output) -> Conduit input m output prepareConduit :: Conduit input m output -> ResourceT m (PreparedConduit input m output) -- | The connect operator, which pulls data from a source and pushes to a -- sink. There are three ways this process can terminate: -- --
    --
  1. In the case of a SinkNoData constructor, the source is -- not opened at all, and the output value is returned immediately.
  2. --
  3. The sink returns Done, in which case any leftover input -- is returned via bsourceUnpull the source is closed.
  4. --
  5. The source return Closed, in which case the sink is -- closed.
  6. --
-- -- Note that the input source is converted to a BufferedSource via -- bufferSource. As such, if the input to this function is itself -- a BufferedSource, the call to bsourceClose will have no -- effect, as described in the comments on that instance. ($$) :: (BufferSource bsrc, Resource m) => bsrc m a -> Sink a m b -> ResourceT m b -- | Left fuse, combining a source and a conduit together into a new -- source. ($=) :: (Resource m, BufferSource bsrc) => bsrc m a -> Conduit a m b -> Source m b -- | Right fuse, combining a conduit and a sink together into a new sink. (=$) :: Resource m => Conduit a m b -> Sink b m c -> Sink a m c -- | Middle fuse, combining two conduits together into a new conduit. (=$=) :: Resource m => Conduit a m b -> Conduit b m c -> Conduit a m c -- | Construct a Source with some stateful functions. This function -- address all mutable state for you. -- -- Since 0.0.0 sourceState :: Resource m => state -> (state -> ResourceT m (state, SourceResult output)) -> Source m output -- | Construct a Source based on some IO actions for alloc/release. -- -- Since 0.0.0 sourceIO :: ResourceIO m => IO state -> (state -> IO ()) -> (state -> m (SourceResult output)) -> Source m output -- | Transform the monad a Source lives in. -- -- Since 0.0.0 transSource :: ((Base m) ~ (Base n), Monad m) => (forall a. m a -> n a) -> Source m output -> Source n output -- | Construct a Sink with some stateful functions. This function -- address all mutable state for you. -- -- Since 0.0.0 sinkState :: Resource m => state -> (state -> input -> ResourceT m (state, SinkResult input output)) -> (state -> ResourceT m output) -> Sink input m output -- | Construct a Sink. Note that your push and close functions need -- not explicitly perform any cleanup. -- -- Since 0.0.0 sinkIO :: ResourceIO m => IO state -> (state -> IO ()) -> (state -> input -> m (SinkResult input output)) -> (state -> m output) -> Sink input m output -- | Transform the monad a Sink lives in. -- -- Since 0.0.0 transSink :: ((Base m) ~ (Base n), Monad m) => (forall a. m a -> n a) -> Sink input m output -> Sink input n output -- | Construct a Conduit with some stateful functions. This function -- address all mutable state for you. -- -- Since 0.0.0 conduitState :: Resource m => state -> (state -> input -> ResourceT m (state, ConduitResult input output)) -> (state -> ResourceT m [output]) -> Conduit input m output -- | Construct a Conduit. -- -- Since 0.0.0 conduitIO :: ResourceIO m => IO state -> (state -> IO ()) -> (state -> input -> m (ConduitResult input output)) -> (state -> m [output]) -> Conduit input m output -- | Transform the monad a Conduit lives in. -- -- Since 0.0.0 transConduit :: (Monad m, (Base m) ~ (Base n)) => (forall a. m a -> n a) -> Conduit input m output -> Conduit input n 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.0.0 type SequencedSink state input m output = state -> Sink input m (SequencedSinkResponse state input m output) -- | Convert a SequencedSink into a Conduit. -- -- Since 0.0.0 sequenceSink :: Resource m => state -> SequencedSink state input m output -> Conduit input m output -- | Return value from a SequencedSink. -- -- Since 0.0.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 -- | 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 with or -- withIO. The with functions correspond 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. data ResourceT m a -- | A Monad with a base that has mutable references, and allows -- some way to run base actions and clean up properly. class (HasRef (Base m), Monad m) => Resource m where { type family Base m :: * -> *; } resourceLiftBase :: Resource m => Base m a -> m a resourceBracket_ :: Resource m => Base m () -> Base m () -> m c -> m c -- | A Resource which can safely run IO calls. class (ResourceBaseIO (Base m), ResourceUnsafeIO m, ResourceThrow m, MonadIO m, MonadBaseControl IO m) => ResourceIO m -- | A Resource based on some monad which allows running of some -- IO actions, via unsafe calls. This applies to IO and -- ST, for instance. class Resource m => ResourceUnsafeIO m -- | 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. runResourceT :: Resource m => ResourceT m a -> m a -- | A Resource which can throw exceptions. Note that this does not -- work in a vanilla ST monad. Instead, you should use the -- ExceptionT transformer on top of ST. class Resource m => ResourceThrow m resourceThrow :: (ResourceThrow m, Exception e) => e -> m a -- | Functions for interacting with bytes. module Data.Conduit.Binary -- | Stream the contents of a file as binary data. -- -- Since 0.0.0 sourceFile :: ResourceIO m => FilePath -> Source 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.0.2. sourceHandle :: ResourceIO m => Handle -> Source 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.0.0 sourceFileRange :: ResourceIO m => FilePath -> Maybe Integer -> Maybe Integer -> Source m ByteString -- | Stream all incoming data to the given file. -- -- Since 0.0.0 sinkFile :: ResourceIO m => FilePath -> Sink 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.0.2. sinkHandle :: ResourceIO m => Handle -> Sink 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.0.0 conduitFile :: ResourceIO m => FilePath -> Conduit ByteString m ByteString -- | 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.0.0 isolate :: Resource m => Int -> Conduit ByteString m ByteString -- | Open a file Handle safely by automatically registering a -- release action. -- -- While you are not required to call hClose on the resulting -- handle, you should do so as early as possible to free scarce -- resources. -- -- Since 0.0.2 openFile :: ResourceIO m => FilePath -> IOMode -> ResourceT m Handle -- | Return the next byte from the stream, if available. -- -- Since 0.0.2 head :: Resource m => Sink ByteString m (Maybe Word8) -- | Return all bytes while the predicate returns True. -- -- Since 0.0.2 takeWhile :: Resource m => (Word8 -> Bool) -> Conduit ByteString m ByteString -- | Ignore all bytes while the predicate returns True. -- -- Since 0.0.2 dropWhile :: Resource m => (Word8 -> Bool) -> Sink ByteString m () -- | 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.0.0 sourceList :: Resource m => [a] -> Source m a -- | A strict left fold. -- -- Since 0.0.0 fold :: Resource m => (b -> a -> b) -> b -> Sink 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.0.0 take :: Resource m => Int -> Sink 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.0.0 drop :: Resource m => Int -> Sink a m () -- | Take a single value from the stream, if available. -- -- Since 0.0.0 head :: Resource m => Sink 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.0.0 peek :: Resource m => Sink 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.0.0 consume :: Resource m => Sink a m [a] -- | Ignore the remainder of values in the source. Particularly useful when -- combined with isolate. -- -- Since 0.0.0 sinkNull :: Resource m => Sink a m () -- | A monadic strict left fold. -- -- Since 0.0.0 foldM :: Resource m => (b -> a -> m b) -> b -> Sink a m b -- | Apply the action to all values in the stream. -- -- Since 0.0.0 mapM_ :: Resource m => (a -> m ()) -> Sink a m () -- | Apply a transformation to all values in a stream. -- -- Since 0.0.0 map :: Monad m => (a -> b) -> Conduit a m b -- | Apply a transformation to all values in a stream, concatenating the -- output values. -- -- Since 0.0.0 concatMap :: Monad m => (a -> [b]) -> Conduit a m b -- | Grouping input according to an equality function. -- -- Since 0.0.2 groupBy :: Resource m => (a -> a -> Bool) -> Conduit 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.0.0 isolate :: Resource m => Int -> Conduit a m a -- | Keep only values in the stream passing a given predicate. -- -- Since 0.0.0 filter :: Resource 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_. -- -- Since 0.0.0 mapM :: Monad m => (a -> m b) -> Conduit a m b -- | Apply a monadic transformation to all values in a stream, -- concatenating the output values. -- -- Since 0.0.0 concatMapM :: Monad m => (a -> m [b]) -> Conduit a m b -- | 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.0.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.0.0 encode :: ResourceThrow m => Codec -> Conduit 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.0.0 decode :: ResourceThrow m => Codec -> Conduit ByteString m Text -- | Since 0.0.0 utf8 :: Codec -- | Since 0.0.0 utf16_le :: Codec -- | Since 0.0.0 utf16_be :: Codec -- | Since 0.0.0 utf32_le :: Codec -- | Since 0.0.0 utf32_be :: Codec -- | Since 0.0.0 ascii :: Codec -- | Since 0.0.0 iso8859_1 :: Codec 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. However, if you consume the content -- within the ResourceT, you should be safe. module Data.Conduit.Lazy -- | Use lazy I/O to consume all elements from a Source. -- -- Since 0.0.0 lazyConsume :: MonadBaseControl IO m => Source m a -> ResourceT m [a]