@@ -8,14 +8,21 @@
9-- Combinators to efficiently manipulate streams of immutable arrays.
9-- Combinators to efficiently manipulate streams of immutable arrays.
11+-- We can either push these in the MutArray module with a "chunks" prefix or
12+-- keep this as a separate module and release it.
11module Streamly.Internal.Data.Array.Stream
14module Streamly.Internal.Data.Array.Stream
13 -- * Creation
16 -- * Creation
14− chunksOf
17+ Array.chunksOf
18+ , Array.pinnedChunksOf
16 -- * Flattening to elements
21 -- * Flattening to elements
23+ , Array.flattenArrays
18 , concatRev
24 , concatRev
25+ , Array.flattenArraysRev
19 , interpose
26 , interpose
20 , interposeSuffix
27 , interposeSuffix
21 , intercalateSuffix
28 , intercalateSuffix
@@ -27,7 +34,7 @@ module Streamly.Internal.Data.Array.Stream
27 -- can flatten the stream to byte stream and use that. But if we want the
34 -- can flatten the stream to byte stream and use that. But if we want the
28 -- remaining stream to be a chunk stream then this could be handy. But it
35 -- remaining stream to be a chunk stream then this could be handy. But it
29 -- could also be implemented using parseBreak.
36 -- could also be implemented using parseBreak.
30− , foldBreak -- StreamK.foldBreakChunks
37+ , foldBreak
31 , foldBreakD
38 , foldBreakD
32 -- The byte level parseBreak cannot work efficiently. Because the stream
39 -- The byte level parseBreak cannot work efficiently. Because the stream
33 -- will have to be a StreamK for backtracking, StreamK at byte level would
40 -- will have to be a StreamK for backtracking, StreamK at byte level would
@@ -36,15 +43,17 @@ module Streamly.Internal.Data.Array.Stream
36 -- , parseBreakD
43 -- , parseBreakD
37 -- , foldManyChunks
44 -- , foldManyChunks
38 -- , parseManyChunks
45 -- , parseManyChunks
40 -- ** Array Folds
49 -- ** Array Folds
41− -- XXX Use Parser.Chunked instead, need only chunkedParseBreak,
50+ -- XXX Use parseBreakChunks/parseChunks instead
42 -- foldBreak can be implemented using parseBreak. Use StreamK.
51 -- foldBreak can be implemented using parseBreak. Use StreamK.
43 , runArrayFold
52 , runArrayFold
44 , runArrayFoldBreak
53 , runArrayFoldBreak
45 -- , parseArr
54 -- , parseArr
46− , runArrayParserDBreak -- StreamK.chunkedParseBreak
55+ , runArrayParserDBreak -- StreamK.parseBreakChunks
47− , runArrayFoldMany -- StreamK.chunkedParseMany
56+ , runArrayFoldMany
@@ -100,21 +109,6 @@ import qualified Streamly.Internal.Data.StreamK as K
100-- XXX Since these are immutable arrays MonadIO constraint can be removed from
109-- XXX Since these are immutable arrays MonadIO constraint can be removed from
101-- most places.
110-- most places.
103−-------------------------------------------------------------------------------
105−-------------------------------------------------------------------------------
107−-- | @chunksOf n stream@ groups the elements in the input stream into arrays of
108−-- @n@ elements each.
110−-- > chunksOf n = Stream.groupsOf n (Array.writeN n)
113−{-# INLINE chunksOf #-}
114−chunksOf :: (MonadIO m, Unbox a)
115− => Int -> Stream m a -> Stream m (Array a)
116−chunksOf = A.chunksOf
118-------------------------------------------------------------------------------
112-------------------------------------------------------------------------------
120-------------------------------------------------------------------------------
114-------------------------------------------------------------------------------