-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Reliable, high-performance processing with left-fold enumerators -- -- Typical buffer–based incremental I/O is based around a single loop, -- which reads data from some source (such as a socket or file), -- transforms it, and generates one or more outputs (such as a line -- count, HTTP responses, or modified file). Although efficient and safe, -- these loops are all single–purpose; it is difficult or impossible to -- compose buffer–based processing loops. -- -- Haskell’s concept of “lazy I/O” allows pure code to operate on data -- from an external source. However, lazy I/O has several shortcomings. -- Most notably, resources such as memory and file handles can be -- retained for arbitrarily long periods of time, causing unpredictable -- performance and error conditions. -- -- Enumerators are an efficient, predictable, and safe alternative to -- lazy I/O. Discovered by Oleg Kiselyov, they allow large datasets to be -- processed in near–constant space by pure code. Although somewhat more -- complex to write, using enumerators instead of lazy I/O produces more -- correct programs. -- -- This library contains an enumerator implementation for Haskell, -- designed to be both simple and efficient. Three core types are -- defined, along with numerous helper functions: -- --
-- import qualified Data.Enumerator as E --module Data.Enumerator -- | A Stream is a sequence of chunks generated by an -- Enumerator. -- -- (Chunks []) is used to indicate that a stream is still -- active, but currently has no available data. Iteratees should ignore -- empty chunks. data Stream a Chunks :: [a] -> Stream a EOF :: Stream a -- | The primary data type for this library, which consumes input from a -- Stream until it either generates a value or encounters an -- error. Rather than requiring all input at once, an iteratee will -- return Continue when it is capable of processing more data. -- -- In general, iteratees begin in the Continue state. As each -- chunk is passed to the continuation, the iteratee returns the next -- step: Continue for more data, Yield when it's finished, -- or Error to abort processing. newtype Iteratee a m b Iteratee :: m (Step a m b) -> Iteratee a m b runIteratee :: Iteratee a m b -> m (Step a m b) data Step a m b -- | The Iteratee is capable of accepting more input. Note that more -- input is not necessarily required; the Iteratee might be able -- to generate a value immediately if it receives EOF. Continue :: (Stream a -> Iteratee a m b) -> Step a m b -- | The Iteratee cannot receive any more input, and has generated a -- result. Included in this value is left-over input, which can be passed -- to composed Iteratees. Yield :: b -> (Stream a) -> Step a m b -- | The Iteratee encountered an error which prevents it from -- proceeding further. Error :: SomeException -> Step a m b -- | While Iteratees consume data, enumerators generate it. Since -- Iteratee is an alias for m (Step a m -- b), Enumerators can be considered step transformers of -- type Step a m b -> m (Step a m b). -- -- Enumerators typically read from an external source (parser, -- handle, random generator, etc). They feed chunks into an -- Iteratee until the source runs out of data (triggering -- EOF) or the iteratee finishes processing (Yields a -- value). type Enumerator a m b = Step a m b -> Iteratee a m b -- | In cases where an enumerator acts as both a source and sink, the -- resulting type is named an Enumeratee. Enumeratees have two -- input types, “outer a” (aOut) and “inner a” (aIn). type Enumeratee ao ai m b = Step ai m b -> Iteratee ao m (Step ai m b) -- |
-- returnI step = Iteratee (return step) --returnI :: Monad m => Step a m b -> Iteratee a m b -- |
-- continue k = returnI (Continue k) --continue :: Monad m => (Stream a -> Iteratee a m b) -> Iteratee a m b -- |
-- yield x extra = returnI (Yield x extra) ---- -- WARNING: due to the current encoding of iteratees in this library, -- careless use of the yield primitive may violate the monad laws. -- To prevent this, always make sure that an iteratee never yields extra -- data unless it has received at least one input element. -- -- More strictly, iteratees may not yield data that they did not receive -- as input. Don't use yield to “inject” elements into the stream. yield :: Monad m => b -> Stream a -> Iteratee a m b -- | Equivalent to '(>>=)' for m (Step a m b); allows -- Iteratees with different input types to be composed. (>>==) :: Monad m => Iteratee a m b -> (Step a m b -> Iteratee a' m b') -> Iteratee a' m b' -- |
-- '(==<<)' = flip '(>>==)' --(==<<) :: Monad m => (Step a m b -> Iteratee a' m b') -> Iteratee a m b -> Iteratee a' m b' -- |
-- '($$)' = '(==<<)' ---- -- This might be easier to read when passing a chain of iteratees to an -- enumerator. -- -- Since: 0.1.1 ($$) :: Monad m => (Step a m b -> Iteratee a' m b') -> Iteratee a m b -> Iteratee a' m b' -- |
-- '(>==>)' e1 e2 s = e1 s >>== e2 ---- -- Since: 0.1.1 (>==>) :: Monad m => Enumerator a m b -> (Step a m b -> Iteratee a' m b') -> Step a m b -> Iteratee a' m b' -- |
-- '(<==<)' = flip '(>==>)' ---- -- Since: 0.1.1 (<==<) :: Monad m => (Step a m b -> Iteratee a' m b') -> Enumerator a m b -> Step a m b -> Iteratee a' m b' (=$) :: Monad m => Enumeratee ao ai m b -> Iteratee ai m b -> Iteratee ao m b -- |
-- enum $= enee = joinE enum enee ---- -- “Wraps” an enumerator inner in an enumeratee wrapper. -- The resulting enumerator will generate wrapper’s output type. -- -- As an example, consider an enumerator that yields line character -- counts for a text file (e.g. for source code readability checking): -- --
-- enumFileCounts :: FilePath -> Enumerator Int IO b ---- -- It could be written with either joinE or '($=)': -- --
-- import Data.Text as T -- import Data.Enumerator.List as EL -- import Data.Enumerator.Text as ET -- -- enumFileCounts path = joinE (enumFile path) (EL.map T.length) -- enumFileCounts path = enumFile path $= EL.map T.length ---- -- Since: 0.4.9 ($=) :: Monad m => Enumerator ao m (Step ai m b) -> Enumeratee ao ai m b -> Enumerator ai m b -- | Run an iteratee until it finishes, and return either the final value -- (if it succeeded) or the error (if it failed). run :: Monad m => Iteratee a m b -> m (Either SomeException b) -- | Like run, except errors are converted to exceptions and thrown. -- Primarily useful for small scripts or other simple cases. -- -- Since: 0.4.1 run_ :: Monad m => Iteratee a m b -> m b -- |
-- throwError exc = returnI (Error (toException exc)) --throwError :: (Monad m, Exception e) => e -> Iteratee a m b -- | Runs the iteratee, and calls an exception handler if an Error -- is returned. By handling errors within the enumerator library, and -- requiring all errors to be represented by SomeException, -- libraries with varying error types can be easily composed. -- -- Since: 0.1.1 catchError :: Monad m => Iteratee a m b -> (SomeException -> Iteratee a m b) -> Iteratee a m b -- | Compose a list of Enumerators using '(>>==)' concatEnums :: Monad m => [Enumerator a m b] -> Enumerator a m b -- | joinI is used to “flatten” Enumeratees into an -- Iteratee. joinI :: Monad m => Iteratee a m (Step a' m b) -> Iteratee a m b -- | Flatten an enumerator/enumeratee pair into a single enumerator. joinE :: Monad m => Enumerator ao m (Step ai m b) -> Enumeratee ao ai m b -> Enumerator ai m b -- | Feeds outer input elements into the provided iteratee until it yields -- an inner input, passes that to the inner iteratee, and then loops. sequence :: Monad m => Iteratee ao m ai -> Enumeratee ao ai m b -- | Sends EOF to its iteratee. Most clients should use run -- or run_ instead. enumEOF :: Monad m => Enumerator a m b -- | A common pattern in Enumerator implementations is to check -- whether the inner Iteratee has finished, and if so, to return -- its output. checkContinue0 passes its parameter a continuation -- if the Iteratee can still consume input; if not, it returns the -- iteratee's step. -- -- The type signature here is a bit crazy, but it's actually very easy to -- use. Take this code: -- --
-- repeat :: Monad m => a -> Enumerator a m b -- repeat x = loop where -- loop (Continue k) = k (Chunks [x]) >>== loop -- loop step = returnI step ---- -- And rewrite it without the boilerplate: -- --
-- repeat :: Monad m => a -> Enumerator a m b -- repeat x = checkContinue0 $ \loop k -> k (Chunks [x] >>== loop ---- -- Since: 0.4.9 checkContinue0 :: Monad m => (Enumerator a m b -> (Stream a -> Iteratee a m b) -> Iteratee a m b) -> Enumerator a m b -- | Like checkContinue0, but allows each loop step to use a state -- value: -- --
-- iterate :: Monad m => (a -> a) -> a -> Enumerator a m b -- iterate f = checkContinue1 $ \loop a k -> k (Chunks [a]) >>== loop (f a) ---- -- Since: 0.4.9 checkContinue1 :: Monad m => ((s1 -> Enumerator a m b) -> s1 -> (Stream a -> Iteratee a m b) -> Iteratee a m b) -> s1 -> Enumerator a m b -- | A common pattern in Enumeratee implementations is to check -- whether the inner Iteratee has finished, and if so, to return -- its output. checkDone passes its parameter a continuation if -- the Iteratee can still consume input, or yields otherwise. -- -- Since: 0.4.3 checkDoneEx :: Monad m => Stream a' -> ((Stream a -> Iteratee a m b) -> Iteratee a' m (Step a m b)) -> Enumeratee a' a m b -- |
-- checkDone = checkDoneEx (Chunks []) ---- -- Use this for enumeratees which do not have an input buffer. checkDone :: Monad m => ((Stream a -> Iteratee a m b) -> Iteratee a' m (Step a m b)) -> Enumeratee a' a m b -- | Check whether a stream has reached EOF. Most clients should use -- Data.Enumerator.List.head instead. isEOF :: Monad m => Iteratee a m Bool -- | Try to run an IO computation. If it throws an exception, the exception -- is caught and converted into an {tt Error}. -- -- Since: 0.4.9 tryIO :: MonadIO m => IO b -> Iteratee a m b -- | Print chunks as they're received from the enumerator, optionally -- printing empty chunks. printChunks :: (MonadIO m, Show a) => Bool -> Iteratee a m () -- | enumList n xs enumerates xs as a stream, -- passing n inputs per chunk. -- -- Primarily useful for testing and debugging. enumList :: Monad m => Integer -> [a] -> Enumerator a m b -- | Lift an Iteratee onto a monad transformer, re-wrapping the -- Iteratee’s inner monadic values. -- -- Since: 0.1.1 liftTrans :: (Monad m, MonadTrans t, Monad (t m)) => Iteratee a m b -> Iteratee a (t m) b -- | Deprecated in 0.4.5: use continue instead liftI :: Monad m => (Stream a -> Step a m b) -> Iteratee a m b -- | Peek at the next element in the stream, or Nothing if the -- stream has ended. peek :: Monad m => Iteratee a m (Maybe a) -- | Get the last element in the stream, or Nothing if the stream -- has ended. -- -- Consumes the entire stream. last :: Monad m => Iteratee a m (Maybe a) -- | Get how many elements remained in the stream. -- -- Consumes the entire stream. length :: Monad m => Iteratee a m Integer -- | Deprecated in 0.4.5: use Data.Enumerator.List.head instead head :: Monad m => Iteratee a m (Maybe a) -- | Deprecated in 0.4.5: use Data.Enumerator.List.drop instead drop :: Monad m => Integer -> Iteratee a m () -- | Deprecated in 0.4.5: use Data.Enumerator.List.dropWhile -- instead dropWhile :: Monad m => (a -> Bool) -> Iteratee a m () -- | Deprecated in 0.4.5: use Data.Enumerator.List.takeWhile -- instead span :: Monad m => (a -> Bool) -> Iteratee a m [a] -- | Deprecated in 0.4.5: use Data.Enumerator.List.takeWhile -- instead break :: Monad m => (a -> Bool) -> Iteratee a m [a] -- | Deprecated in 0.4.5: use Data.Enumerator.List.consume instead consume :: Monad m => Iteratee a m [a] -- | Deprecated in 0.4.8: use Data.Enumerator.List.fold instead -- -- Since: 0.4.5 foldl :: Monad m => (b -> a -> b) -> b -> Iteratee a m b -- | Deprecated in 0.4.8: use Data.Enumerator.List.fold instead -- -- Since: 0.4.5 foldl' :: Monad m => (b -> a -> b) -> b -> Iteratee a m b -- | Deprecated in 0.4.8: use Data.Enumerator.List.foldM instead -- -- Since: 0.4.5 foldM :: Monad m => (b -> a -> m b) -> b -> Iteratee a m b -- | Deprecated in 0.4.8: use Data.Enumerator.List.iterate instead -- -- Since: 0.4.5 iterate :: Monad m => (a -> a) -> a -> Enumerator a m b -- | Deprecated in 0.4.8: use Data.Enumerator.List.iterateM -- instead -- -- Since: 0.4.5 iterateM :: Monad m => (a -> m a) -> a -> Enumerator a m b -- | Deprecated in 0.4.8: use Data.Enumerator.List.repeat instead -- -- Since: 0.4.5 repeat :: Monad m => a -> Enumerator a m b -- | Deprecated in 0.4.8: use Data.Enumerator.List.repeatM instead -- -- Since: 0.4.5 repeatM :: Monad m => m a -> Enumerator a m b -- | Deprecated in 0.4.8: use Data.Enumerator.List.replicate -- instead -- -- Since: 0.4.5 replicate :: Monad m => Integer -> a -> Enumerator a m b -- | Deprecated in 0.4.8: use Data.Enumerator.List.replicateM -- instead -- -- Since: 0.4.5 replicateM :: Monad m => Integer -> m a -> Enumerator a m b -- | Deprecated in 0.4.8: use Data.Enumerator.List.generateM -- instead -- -- Since: 0.4.5 generateM :: Monad m => m (Maybe a) -> Enumerator a m b -- | Deprecated in 0.4.8: use Data.Enumerator.List.map instead map :: Monad m => (ao -> ai) -> Enumeratee ao ai m b -- | Deprecated in 0.4.8: use Data.Enumerator.List.mapM instead -- -- Since: 0.4.3 mapM :: Monad m => (ao -> m ai) -> Enumeratee ao ai m b -- | Deprecated in 0.4.8: use Data.Enumerator.List.concatMap -- instead -- -- Since: 0.4.3 concatMap :: Monad m => (ao -> [ai]) -> Enumeratee ao ai m b -- | Deprecated in 0.4.8: use Data.Enumerator.List.concatMapM -- instead -- -- Since: 0.4.5 concatMapM :: Monad m => (ao -> m [ai]) -> Enumeratee ao ai m b -- | Deprecated in 0.4.8: use Data.Enumerator.List.filter instead -- -- Since: 0.4.5 filter :: Monad m => (a -> Bool) -> Enumeratee a a m b -- | Deprecated in 0.4.8: use Data.Enumerator.List.filterM instead -- -- Since: 0.4.5 filterM :: Monad m => (a -> m Bool) -> Enumeratee a a m b -- | Deprecated in 0.4.5: use Data.Enumerator.List.fold instead -- -- Since: 0.1.1 liftFoldL :: Monad m => (b -> a -> b) -> b -> Iteratee a m b -- | Deprecated in 0.4.5: use Data.Enumerator.List.fold instead -- -- Since: 0.1.1 liftFoldL' :: Monad m => (b -> a -> b) -> b -> Iteratee a m b -- | Deprecated in 0.4.5: use Data.Enumerator.List.foldM instead -- -- Since: 0.1.1 liftFoldM :: Monad m => (b -> a -> m b) -> b -> Iteratee a m b instance Show a => Show (Stream a) instance Eq a => Eq (Stream a) instance Applicative Stream instance Functor Stream instance Monad m => Applicative (Iteratee a m) instance Monad m => Functor (Iteratee a m) instance (Typeable a, Typeable1 m) => Typeable1 (Step a m) instance (Typeable a, Typeable1 m) => Typeable1 (Iteratee a m) instance Typeable1 Stream instance MonadIO m => MonadIO (Iteratee a m) instance MonadTrans (Iteratee a) instance Monad m => Monad (Iteratee a m) instance Monoid (Stream a) instance Monad Stream -- | This module is intended to be imported qualified: -- --
-- import qualified Data.Enumerator.List as EL ---- -- Since: 0.4.5 module Data.Enumerator.List -- | Consume the entire input stream with a strict left fold, one element -- at a time. -- -- Since: 0.4.8 fold :: Monad m => (b -> a -> b) -> b -> Iteratee a m b -- | Consume the entire input stream with a strict monadic left fold, one -- element at a time. -- -- Since: 0.4.8 foldM :: Monad m => (b -> a -> m b) -> b -> Iteratee a m b -- | map f applies f to each input element and feeds -- the resulting outputs to the inner iteratee. -- -- Since: 0.4.8 map :: Monad m => (ao -> ai) -> Enumeratee ao ai m b -- | mapM f applies f to each input element and -- feeds the resulting outputs to the inner iteratee. -- -- Since: 0.4.8 mapM :: Monad m => (ao -> m ai) -> Enumeratee ao ai m b -- | concatMap f applies f to each input element and -- feeds the resulting outputs to the inner iteratee. -- -- Since: 0.4.8 concatMap :: Monad m => (ao -> [ai]) -> Enumeratee ao ai m b -- | concatMapM f applies f to each input element -- and feeds the resulting outputs to the inner iteratee. -- -- Since: 0.4.8 concatMapM :: Monad m => (ao -> m [ai]) -> Enumeratee ao ai m b -- | Similar to map, but with a stateful step function. -- -- Since: 0.4.9 mapAccum :: Monad m => (s -> ao -> (s, ai)) -> s -> Enumeratee ao ai m b -- | Similar to mapM, but with a stateful step function. -- -- Since: 0.4.9 mapAccumM :: Monad m => (s -> ao -> m (s, ai)) -> s -> Enumeratee ao ai m b -- | iterate f x enumerates an infinite stream of repeated -- applications of f to x. -- -- Analogous to iterate. -- -- Since: 0.4.8 iterate :: Monad m => (a -> a) -> a -> Enumerator a m b -- | Similar to iterate, except the iteration function is monadic. -- -- Since: 0.4.8 iterateM :: Monad m => (a -> m a) -> a -> Enumerator a m b -- | Enumerates an infinite stream of a single element. -- -- Analogous to repeat. -- -- Since: 0.4.8 repeat :: Monad m => a -> Enumerator a m b -- | Enumerates an infinite stream of element. Each element is computed by -- the underlying monad. -- -- Since: 0.4.8 repeatM :: Monad m => m a -> Enumerator a m b -- | replicate n x enumerates a stream containing n -- copies of x. -- -- Analogous to replicate. -- -- Since: 0.4.8 replicate :: Monad m => Integer -> a -> Enumerator a m b -- | replicateM n m_x enumerates a stream of n -- elements, with each element computed by m_x. -- -- Since: 0.4.8 replicateM :: Monad m => Integer -> m a -> Enumerator a m b -- | Like repeatM, except the computation may terminate the stream -- by returning Nothing. -- -- Since: 0.4.8 generateM :: Monad m => m (Maybe a) -> Enumerator a m b -- | Enumerates a stream of elements by repeatedly applying a function to -- some state. -- -- Similar to iterate. -- -- Since: 0.4.8 unfold :: Monad m => (s -> Maybe (a, s)) -> s -> Enumerator a m b -- | Enumerates a stream of elements by repeatedly applying a computation -- to some state. -- -- Similar to iterateM. -- -- Since: 0.4.8 unfoldM :: Monad m => (s -> m (Maybe (a, s))) -> s -> Enumerator a m b -- | Applies a predicate to the stream. The inner iteratee only receives -- elements for which the predicate is True. -- -- Since: 0.4.8 filter :: Monad m => (a -> Bool) -> Enumeratee a a m b -- | Applies a monadic predicate to the stream. The inner iteratee only -- receives elements for which the predicate returns True. -- -- Since: 0.4.8 filterM :: Monad m => (a -> m Bool) -> Enumeratee a a m b -- | take n extracts the next n elements from the -- stream, as a list. -- -- Since: 0.4.5 take :: Monad m => Integer -> Iteratee a m [a] -- | takeWhile p extracts input from the stream until the -- first element which does not match the predicate. -- -- Since: 0.4.5 takeWhile :: Monad m => (a -> Bool) -> Iteratee a m [a] -- |
-- consume = takeWhile (const True) ---- -- Since: 0.4.5 consume :: Monad m => Iteratee a m [a] -- | Get the next element from the stream, or Nothing if the stream -- has ended. -- -- Since: 0.4.5 head :: Monad m => Iteratee a m (Maybe a) -- | drop n ignores n input elements from the -- stream. -- -- Since: 0.4.5 drop :: Monad m => Integer -> Iteratee a m () -- | dropWhile p ignores input from the stream until the -- first element which does not match the predicate. -- -- Since: 0.4.5 dropWhile :: Monad m => (a -> Bool) -> Iteratee a m () -- | require n buffers input until at least n -- elements are available, or throws an error if the stream ends early. -- -- Since: 0.4.5 require :: Monad m => Integer -> Iteratee a m () -- | isolate n reads at most n elements from the -- stream, and passes them to its iteratee. If the iteratee finishes -- early, elements continue to be consumed from the outer stream until -- n have been consumed. -- -- Since: 0.4.5 isolate :: Monad m => Integer -> Enumeratee a a m b -- | Split on elements satisfying a given predicate. -- -- Since: 0.4.8 splitWhen :: Monad m => (a -> Bool) -> Enumeratee a [a] m b -- | This module is intended to be imported qualified: -- --
-- import qualified Data.Enumerator.Binary as EB ---- -- Since: 0.4.5 module Data.Enumerator.Binary -- | Read bytes (in chunks of the given buffer size) from the handle, and -- stream them to an Iteratee. If an exception occurs during file -- IO, enumeration will stop and Error will be returned. -- Exceptions from the iteratee are not caught. -- -- This enumerator blocks until at least one byte is available from the -- handle, and might read less than the maximum buffer size in some -- cases. -- -- The handle should be opened with no encoding, and in ReadMode -- or ReadWriteMode. -- -- Since: 0.4.5 enumHandle :: MonadIO m => Integer -> Handle -> Enumerator ByteString m b -- | Read bytes (in chunks of the given buffer size) from the handle, and -- stream them to an Iteratee. If an exception occurs during file -- IO, enumeration will stop and Error will be returned. -- Exceptions from the iteratee are not caught. -- -- This enumerator blocks until at least one byte is available from the -- handle, and might read less than the maximum buffer size in some -- cases. -- -- The handle should be opened with no encoding, and in ReadMode -- or ReadWriteMode. -- -- If an offset is specified, the handle will be seeked to that offset -- before reading. If the handle cannot be seeked, an error will be -- thrown. -- -- If a maximum count is specified, the number of bytes read will not -- exceed that count. -- -- Since: 0.4.8 enumHandleRange :: MonadIO m => Integer -> Maybe Integer -> Maybe Integer -> Handle -> Enumerator ByteString m b -- | Opens a file path in binary mode, and passes the handle to -- enumHandle. The file will be closed when enumeration finishes. -- -- Since: 0.4.5 enumFile :: FilePath -> Enumerator ByteString IO b -- | Opens a file path in binary mode, and passes the handle to -- enumHandleRange. The file will be closed when enumeration -- finishes. -- -- Since: 0.4.8 enumFileRange :: FilePath -> Maybe Integer -> Maybe Integer -> Enumerator ByteString IO b -- | Read bytes from a stream and write them to a handle. If an exception -- occurs during file IO, enumeration will stop and Error will be -- returned. -- -- The handle should be opened with no encoding, and in WriteMode -- or ReadWriteMode. -- -- Since: 0.4.5 iterHandle :: MonadIO m => Handle -> Iteratee ByteString m () -- | Consume the entire input stream with a strict left fold, one byte at a -- time. -- -- Since: 0.4.8 fold :: Monad m => (b -> Word8 -> b) -> b -> Iteratee ByteString m b -- | Consume the entire input stream with a strict monadic left fold, one -- byte at a time. -- -- Since: 0.4.8 foldM :: Monad m => (b -> Word8 -> m b) -> b -> Iteratee ByteString m b -- | map f applies f to each input byte and feeds -- the resulting outputs to the inner iteratee. -- -- Since: 0.4.8 map :: Monad m => (Word8 -> Word8) -> Enumeratee ByteString ByteString m b -- | mapM f applies f to each input byte and feeds -- the resulting outputs to the inner iteratee. -- -- Since: 0.4.8 mapM :: Monad m => (Word8 -> m Word8) -> Enumeratee ByteString ByteString m b -- | concatMap f applies f to each input byte and -- feeds the resulting outputs to the inner iteratee. -- -- Since: 0.4.8 concatMap :: Monad m => (Word8 -> ByteString) -> Enumeratee ByteString ByteString m b -- | concatMapM f applies f to each input byte and -- feeds the resulting outputs to the inner iteratee. -- -- Since: 0.4.8 concatMapM :: Monad m => (Word8 -> m ByteString) -> Enumeratee ByteString ByteString m b -- | Similar to map, but with a stateful step function. -- -- Since: 0.4.9 mapAccum :: Monad m => (s -> Word8 -> (s, Word8)) -> s -> Enumeratee ByteString ByteString m b -- | Similar to mapM, but with a stateful step function. -- -- Since: 0.4.9 mapAccumM :: Monad m => (s -> Word8 -> m (s, Word8)) -> s -> Enumeratee ByteString ByteString m b -- | iterate f x enumerates an infinite stream of repeated -- applications of f to x. -- -- Analogous to iterate. -- -- Since: 0.4.8 iterate :: Monad m => (Word8 -> Word8) -> Word8 -> Enumerator ByteString m b -- | Similar to iterate, except the iteration function is monadic. -- -- Since: 0.4.8 iterateM :: Monad m => (Word8 -> m Word8) -> Word8 -> Enumerator ByteString m b -- | Enumerates an infinite stream of a single byte. -- -- Analogous to repeat. -- -- Since: 0.4.8 repeat :: Monad m => Word8 -> Enumerator ByteString m b -- | Enumerates an infinite stream of byte. Each byte is computed by the -- underlying monad. -- -- Since: 0.4.8 repeatM :: Monad m => m Word8 -> Enumerator ByteString m b -- | replicate n x enumerates a stream containing n -- copies of x. -- -- Since: 0.4.8 replicate :: Monad m => Integer -> Word8 -> Enumerator ByteString m b -- | replicateM n m_x enumerates a stream of n -- bytes, with each byte computed by m_x. -- -- Since: 0.4.8 replicateM :: Monad m => Integer -> m Word8 -> Enumerator ByteString m b -- | Like repeatM, except the computation may terminate the stream -- by returning Nothing. -- -- Since: 0.4.8 generateM :: Monad m => m (Maybe Word8) -> Enumerator ByteString m b -- | Enumerates a stream of bytes by repeatedly applying a function to some -- state. -- -- Similar to iterate. -- -- Since: 0.4.8 unfold :: Monad m => (s -> Maybe (Word8, s)) -> s -> Enumerator ByteString m b -- | Enumerates a stream of bytes by repeatedly applying a computation to -- some state. -- -- Similar to iterateM. -- -- Since: 0.4.8 unfoldM :: Monad m => (s -> m (Maybe (Word8, s))) -> s -> Enumerator ByteString m b -- | Applies a predicate to the stream. The inner iteratee only receives -- characters for which the predicate is True. -- -- Since: 0.4.8 filter :: Monad m => (Word8 -> Bool) -> Enumeratee ByteString ByteString m b -- | Applies a monadic predicate to the stream. The inner iteratee only -- receives bytes for which the predicate returns True. -- -- Since: 0.4.8 filterM :: Monad m => (Word8 -> m Bool) -> Enumeratee ByteString ByteString m b -- | take n extracts the next n bytes from the -- stream, as a lazy ByteString. -- -- Since: 0.4.5 take :: Monad m => Integer -> Iteratee ByteString m ByteString -- | takeWhile p extracts input from the stream until the -- first byte which does not match the predicate. -- -- Since: 0.4.5 takeWhile :: Monad m => (Word8 -> Bool) -> Iteratee ByteString m ByteString -- |
-- consume = takeWhile (const True) ---- -- Since: 0.4.5 consume :: Monad m => Iteratee ByteString m ByteString -- | Get the next byte from the stream, or Nothing if the stream has -- ended. -- -- Since: 0.4.5 head :: Monad m => Iteratee ByteString m (Maybe Word8) -- | drop n ignores n bytes of input from the -- stream. -- -- Since: 0.4.5 drop :: Monad m => Integer -> Iteratee ByteString m () -- | dropWhile p ignores input from the stream until the -- first byte which does not match the predicate. -- -- Since: 0.4.5 dropWhile :: Monad m => (Word8 -> Bool) -> Iteratee ByteString m () -- | require n buffers input until at least n bytes -- are available, or throws an error if the stream ends early. -- -- Since: 0.4.5 require :: Monad m => Integer -> Iteratee ByteString m () -- | isolate n reads at most n bytes from the -- stream, and passes them to its iteratee. If the iteratee finishes -- early, bytes continue to be consumed from the outer stream until -- n have been consumed. -- -- Since: 0.4.5 isolate :: Monad m => Integer -> Enumeratee ByteString ByteString m b -- | Split on bytes satisfying a given predicate. -- -- Since: 0.4.8 splitWhen :: Monad m => (Word8 -> Bool) -> Enumeratee ByteString ByteString m b -- | This module is intended to be imported qualified: -- --
-- import qualified Data.Enumerator.Text as ET ---- -- Since: 0.2 module Data.Enumerator.Text -- | Read lines of text from the handle, and stream them to an -- Iteratee. If an exception occurs during file IO, enumeration -- will stop and Error will be returned. Exceptions from the -- iteratee are not caught. -- -- The handle should be opened with an appropriate text encoding, and in -- ReadMode or ReadWriteMode. -- -- Since: 0.2 enumHandle :: MonadIO m => Handle -> Enumerator Text m b -- | Opens a file path in text mode, and passes the handle to -- enumHandle. The file will be closed when the Iteratee -- finishes. -- -- Since: 0.2 enumFile :: FilePath -> Enumerator Text IO b -- | Read text from a stream and write it to a handle. If an exception -- occurs during file IO, enumeration will stop and Error will be -- returned. -- -- The handle should be opened with an appropriate text encoding, and in -- WriteMode or ReadWriteMode. -- -- Since: 0.2 iterHandle :: MonadIO m => Handle -> Iteratee Text m () -- | Consume the entire input stream with a strict left fold, one character -- at a time. -- -- Since: 0.4.8 fold :: Monad m => (b -> Char -> b) -> b -> Iteratee Text m b -- | Consume the entire input stream with a strict monadic left fold, one -- character at a time. -- -- Since: 0.4.8 foldM :: Monad m => (b -> Char -> m b) -> b -> Iteratee Text m b -- | map f applies f to each input character and -- feeds the resulting outputs to the inner iteratee. -- -- Since: 0.4.8 map :: Monad m => (Char -> Char) -> Enumeratee Text Text m b -- | mapM f applies f to each input character and -- feeds the resulting outputs to the inner iteratee. -- -- Since: 0.4.8 mapM :: Monad m => (Char -> m Char) -> Enumeratee Text Text m b -- | concatMap f applies f to each input character -- and feeds the resulting outputs to the inner iteratee. -- -- Since: 0.4.8 concatMap :: Monad m => (Char -> Text) -> Enumeratee Text Text m b -- | concatMapM f applies f to each input character -- and feeds the resulting outputs to the inner iteratee. -- -- Since: 0.4.8 concatMapM :: Monad m => (Char -> m Text) -> Enumeratee Text Text m b -- | Similar to map, but with a stateful step function. -- -- Since: 0.4.9 mapAccum :: Monad m => (s -> Char -> (s, Char)) -> s -> Enumeratee Text Text m b -- | Similar to mapM, but with a stateful step function. -- -- Since: 0.4.9 mapAccumM :: Monad m => (s -> Char -> m (s, Char)) -> s -> Enumeratee Text Text m b -- | iterate f x enumerates an infinite stream of repeated -- applications of f to x. -- -- Analogous to iterate. -- -- Since: 0.4.8 iterate :: Monad m => (Char -> Char) -> Char -> Enumerator Text m b -- | Similar to iterate, except the iteration function is monadic. -- -- Since: 0.4.8 iterateM :: Monad m => (Char -> m Char) -> Char -> Enumerator Text m b -- | Enumerates an infinite stream of a single character. -- -- Analogous to repeat. -- -- Since: 0.4.8 repeat :: Monad m => Char -> Enumerator Text m b -- | Enumerates an infinite stream of characters. Each character is -- computed by the underlying monad. -- -- Since: 0.4.8 repeatM :: Monad m => m Char -> Enumerator Text m b -- | replicate n x enumerates a stream containing n -- copies of x. -- -- Since: 0.4.8 replicate :: Monad m => Integer -> Char -> Enumerator Text m b -- | replicateM n m_x enumerates a stream of n -- characters, with each character computed by m_x. -- -- Since: 0.4.8 replicateM :: Monad m => Integer -> m Char -> Enumerator Text m b -- | Like repeatM, except the computation may terminate the stream -- by returning Nothing. -- -- Since: 0.4.8 generateM :: Monad m => m (Maybe Char) -> Enumerator Text m b -- | Enumerates a stream of characters by repeatedly applying a function to -- some state. -- -- Similar to iterate. -- -- Since: 0.4.8 unfold :: Monad m => (s -> Maybe (Char, s)) -> s -> Enumerator Text m b -- | Enumerates a stream of characters by repeatedly applying a computation -- to some state. -- -- Similar to iterateM. -- -- Since: 0.4.8 unfoldM :: Monad m => (s -> m (Maybe (Char, s))) -> s -> Enumerator Text m b -- | Applies a predicate to the stream. The inner iteratee only receives -- characters for which the predicate is True. -- -- Since: 0.4.8 filter :: Monad m => (Char -> Bool) -> Enumeratee Text Text m b -- | Applies a monadic predicate to the stream. The inner iteratee only -- receives characters for which the predicate returns True. -- -- Since: 0.4.8 filterM :: Monad m => (Char -> m Bool) -> Enumeratee Text Text m b -- | take n extracts the next n characters from the -- stream, as a lazy Text. -- -- Since: 0.4.5 take :: Monad m => Integer -> Iteratee Text m Text -- | takeWhile p extracts input from the stream until the -- first character which does not match the predicate. -- -- Since: 0.4.5 takeWhile :: Monad m => (Char -> Bool) -> Iteratee Text m Text -- |
-- consume = takeWhile (const True) ---- -- Since: 0.4.5 consume :: Monad m => Iteratee Text m Text -- | Get the next character from the stream, or Nothing if the -- stream has ended. -- -- Since: 0.4.5 head :: Monad m => Iteratee Text m (Maybe Char) -- | drop n ignores n characters of input from the -- stream. -- -- Since: 0.4.5 drop :: Monad m => Integer -> Iteratee Text m () -- | dropWhile p ignores input from the stream until the -- first character which does not match the predicate. -- -- Since: 0.4.5 dropWhile :: Monad m => (Char -> Bool) -> Iteratee Text m () -- | require n buffers input until at least n -- characters are available, or throws an error if the stream ends early. -- -- Since: 0.4.5 require :: Monad m => Integer -> Iteratee Text m () -- | isolate n reads at most n characters from the -- stream, and passes them to its iteratee. If the iteratee finishes -- early, characters continue to be consumed from the outer stream until -- n have been consumed. -- -- Since: 0.4.5 isolate :: Monad m => Integer -> Enumeratee Text Text m b -- | Split on characters satisfying a given predicate. -- -- Since: 0.4.8 splitWhen :: Monad m => (Char -> Bool) -> Enumeratee Text Text m b -- |
-- lines = splitWhen (== '\n') ---- -- Since: 0.4.8 lines :: Monad m => Enumeratee Text Text m b data Codec -- | Convert text into bytes, using the provided codec. If the codec is not -- capable of representing an input character, an error will be thrown. -- -- Since: 0.2 encode :: Monad m => Codec -> Enumeratee Text ByteString m b -- | Convert bytes into text, using the provided codec. If the codec is not -- capable of decoding an input byte sequence, an error will be thrown. -- -- Since: 0.2 decode :: Monad m => Codec -> Enumeratee ByteString Text m b utf8 :: Codec utf16_le :: Codec utf16_be :: Codec utf32_le :: Codec utf32_be :: Codec ascii :: Codec iso8859_1 :: Codec instance Show Codec -- | Deprecated in 0.4.5: use Data.Enumerator.Binary instead module Data.Enumerator.IO -- | Deprecated in 0.4.5: use enumHandle instead enumHandle :: MonadIO m => Integer -> Handle -> Enumerator ByteString m b -- | Deprecated in 0.4.5: use enumFile instead enumFile :: FilePath -> Enumerator ByteString IO b -- | Deprecated in 0.4.5: use iterHandle instead iterHandle :: MonadIO m => Handle -> Iteratee ByteString m ()