DPutils-0.0.2.0: utilities for DP

Safe HaskellNone
LanguageHaskell2010

Data.ByteString.Streaming.Split

Description

Splitting functions for ByteString m r into Stream (ByteString m) m r.

TODO These functions need quickcheck tests.

Synopsis

Documentation

splitsByteStringAt :: Monad m => Int -> ByteString m r -> Stream (ByteString m) m r Source #

Split a ByteString m r after every k characters.

Streams in constant memory.

BUG: Once the stream is exhausted, it will still call splitAt, forever creating empty ByteStrings.

separatesByteString :: Monad m => (ByteString m r -> ByteString m (ByteString m r)) -> ByteString m r -> Stream (ByteString m) m r Source #

For lists, this would be sbs (f :: [a] -> ([a],[a])) -> [a] -> [[a]]. Takes a function that splits the bytestring into two elements repeatedly, where the first is followed by the repeated application of the function.

cf. http://hackage.haskell.org/package/streaming-utils-0.1.4.7/docs/src/Streaming-Pipes.html#chunksOf

TODO these functions should go into a helper library