DPutils- utilities for DP

Safe HaskellNone



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

TODO These functions need quickcheck tests.



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-

TODO these functions should go into a helper library