chunksOf n stream groups the elements in the input stream into arrays of
n elements each.
Same as the following but may be more efficient:
chunksOf n = Stream.foldMany (Array.writeN n)Pre-release
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Modulestreamly-core-0.2.2Haskell2010
Deprecated. Please use Streamly.Internal.Data.Array instead.
Combinators to efficiently manipulate streams of immutable arrays.
We can either push these in the MutArray module with a "chunks" prefix or keep this as a separate module and release it.
chunksOf n stream groups the elements in the input stream into arrays of
n elements each.
Same as the following but may be more efficient:
chunksOf n = Stream.foldMany (Array.writeN n)Pre-release
Like chunksOf but creates pinned arrays.
Deprecated. Please use buildChunks instead.
Convert a stream of arrays into a stream of their elements.
concat = Stream.unfoldMany Array.readerDeprecated. Please use "unfoldMany reader" instead.
Convert a stream of arrays into a stream of their elements reversing the contents of each array before flattening.
concatRev = Stream.unfoldMany Array.readerRevDeprecated. Please use "unfoldMany readerRev" instead.
Insert the given element between arrays and flatten.
interpose x = Stream.interpose x Array.readerInsert the given element after each array and flatten. This is similar to unlines.
interposeSuffix x = Stream.interposeSuffix x Array.readerInsert the given array after each array and flatten.
intercalateSuffix = Stream.intercalateSuffix Array.readerFold an array stream using the supplied Fold. Returns the fold result and the unconsumed stream.
foldBreak f = runArrayFoldBreak (ChunkFold.fromFold f)Instead of using this we can adapt the fold to ParserK and use parseBreakChunks instead. ParserK allows composing using Monad as well.
foldBreak f s =
fmap (first (fromRight undefined))
$ K.parseBreakChunks (ParserK.adaptC (PR.fromFold f)) s
We can compare perf and remove this one or define it in terms of that.
Internal
Parse an array stream using the supplied Parser. Returns the parse
result and the unconsumed stream. Throws ParseError if the parse fails.
> parseBreak p = K.parseBreakChunks (ParserK.adaptC p)This is redundant and we can just use parseBreakChunks, as ParserK can be composed using Monad. The only advantage of this is that we do not need to adapt.
We can compare perf and remove this one or define it in terms of that.
Internal
Fold an array stream using the supplied array stream Fold.
Pre-release
Like fold but also returns the remaining stream.
Pre-release
Note that this is not the same as using a Parser (Array a) m b with the
regular "Streamly.Internal.Data.IsStream.parse" function. The regular parse
would consume the input arrays as single unit. This parser parses in the way
as described in the ChunkFold module. The input arrays are treated as n
element units and can be consumed partially. The remaining elements are
inserted in the source stream as an array.
Apply an ChunkFold repeatedly on an array stream and emit the fold outputs in the output stream.
See "Streamly.Data.Stream.foldMany" for more details.
Pre-release
Given a stream of arrays, splice them all together to generate a single array. The stream must be finite.
Coalesce adjacent arrays in incoming stream to form bigger arrays of a maximum specified size in bytes.
Split a stream of arrays on a given separator byte, dropping the separator and coalescing all the arrays between two separators into a single array.