on master help sign in
merge the ArrayStream module to Array module itself

Each container type (e.g. Handle/Socket/File) may have similar nested/stream level operations. We need a standardized way of naming the combinators related to streams of containers. Also, we cannot have a separate module for such combinators for each container type. Therefore it makes sense to put them in the same module.

commit1bfca9e46c977a01245429f739aa30bf88d45283 authorHarendra Kumar <harendra.kumar@gmail.com> dateThu 15 Aug 2019, 16:07 (7 years ago) parentadc6043
7 files changed+30−18
benchmark/FileIO.hs+2−3 examples/HandleIO.hs+2−3 src/Streamly/Memory/Array.hs+19−3 src/Streamly/Prelude/Internal.hs+2−2 streamly.cabal+1−1 test/Arrays.hs+3−4 test/String.hs+1−2
benchmark/FileIO.hs+2−3
@@ -17,7 +17,6 @@ import Gauge
1717
1818import qualified Streamly.FileSystem.Handle as FH
1919import qualified Streamly.Memory.Array as A
20−import qualified Streamly.Memory.ArrayStream as AS
2120import qualified Streamly.Prelude as S
2221import qualified Streamly.Fold as FL
2322import qualified Streamly.Data.String as SS
@@ -111,7 +110,7 @@ main = do
111110 S.sum (S.map A.length s)
112111 , mkBench "linecount" href $ do
113112 Handles inh _ <- readIORef href
114− S.length $ AS.splitOn 10 $ FH.readArrays inh
113+ S.length $ A.splitOn 10 $ FH.readArrays inh
115114 , mkBench "sum" href $ do
116115 let foldlArr' f z = runIdentity . S.foldl' f z . A.read
117116 Handles inh _ <- readIORef href
@@ -201,7 +200,7 @@ main = do
201200 Handles inh outh <- readIORef href
202201 S.runFold (FH.writeArraysInChunksOf (1024*1024) outh)
203202 $ Internal.insertAfterEach (return $ A.fromList [10])
204− $ AS.splitOn 10
203+ $ A.splitOn 10
205204 $ FH.readArraysOf (1024*1024) inh
206205 , mkBench "words-unwords" href $ do
207206 Handles inh outh <- readIORef href
examples/HandleIO.hs+2−3
@@ -1,7 +1,6 @@
11import qualified Streamly.Prelude as S
22import qualified Streamly.Fold as FL
3−-- import qualified Streamly.Memory.Array as A
4−import qualified Streamly.Memory.ArrayStream as AS
3+import qualified Streamly.Memory.Array as A
54import qualified Streamly.FileSystem.Handle as FH
65import qualified System.IO as FH
76-- import qualified Streamly.FileSystem.FD as FH
@@ -26,7 +25,7 @@ ord' = (fromIntegral . ord)
2625
2726wcl :: FH.Handle -> IO ()
2827wcl src = print =<< (S.length
29− $ AS.splitOn 10
28+ $ A.splitOn 10
3029 $ FH.readArrays src)
3130{-
3231-- Char stream version
src/Streamly/Memory/Array.hs+19−3
@@ -65,7 +65,8 @@ module Streamly.Memory.Array
6565
6666 -- , defaultChunkSize
6767
68− -- * Construction
68+ -- * Arrays
69+ -- ** Construction
6970 -- | When performance matters, the fastest way to generate an array is
7071 -- 'writeN'. For regular use, 'IsList' and 'IsString' instances can be
7172 -- used to conveniently construct arrays from literal values.
@@ -86,7 +87,7 @@ module Streamly.Memory.Array
8687 -- , writeNS
8788 -- , writeS
8889
89− -- * Elimination
90+ -- ** Elimination
9091 -- 'GHC.Exts.toList' from "GHC.Exts" can be used to convert an array to a
9192 -- list.
9293
@@ -94,7 +95,7 @@ module Streamly.Memory.Array
9495 , A.read
9596 , readRev
9697
97− -- * Random Access
98+ -- ** Random Access
9899 , length
99100 -- , (!!)
100101
@@ -118,6 +119,20 @@ module Streamly.Memory.Array
118119 -- , runStreamFold
119120 , runFold
120121 -}
122+
123+ -- * Streams of Arrays
124+ -- ** Creation
125+ , AS.arraysOf
126+
127+ -- ** Elimination
128+ , AS.flatten
129+ -- , AS.concatRev
130+ , AS.unlinesBy
131+ , AS.toArray
132+
133+ -- ** Transformation
134+ , AS.splitOn
135+ , AS.compact -- compact
121136 )
122137where
123138
@@ -136,6 +151,7 @@ import Streamly.Streams.StreamK.Type (IsStream)
136151import Streamly.Fold.Types (Fold(..))
137152
138153import qualified Streamly.Memory.Array.Types as A
154+import qualified Streamly.Memory.ArrayStream as AS
139155import qualified Streamly.Streams.Prelude as P
140156import qualified Streamly.Streams.Serial as Serial
141157import qualified Streamly.Streams.StreamD as D
src/Streamly/Prelude/Internal.hs+2−2
@@ -379,7 +379,7 @@ import qualified System.IO as IO
379379
380380import Streamly.Enumeration (Enumerable(..), enumerate, enumerateTo)
381381import Streamly.Fold.Types (Fold (..))
382−import Streamly.Memory.Array (Array)
382+import Streamly.Memory.Array.Types (Array)
383383-- import Streamly.Memory.Ring (Ring)
384384import Streamly.SVar (MonadAsync, defState)
385385import Streamly.Streams.Async (mkAsync')
@@ -396,7 +396,7 @@ import Streamly.Time.Units
396396
397397import Streamly.Strict
398398
399−import qualified Streamly.Memory.Array as A
399+import qualified Streamly.Memory.Array.Types as A
400400import qualified Streamly.Fold as FL
401401import qualified Streamly.Fold.Types as FL
402402import qualified Streamly.Streams.Prelude as P
streamly.cabal+1−1
@@ -214,6 +214,7 @@ library
214214 , Streamly.Pipe.Types
215215 , Streamly.Pipe
216216
217+ , Streamly.Memory.ArrayStream
217218 , Streamly.Prelude.Internal
218219 , Streamly.FileSystem.IOVec
219220 , Streamly.FileSystem.FDIO
@@ -234,7 +235,6 @@ library
234235
235236 -- IO devices
236237 , Streamly.Memory.Array
237− , Streamly.Memory.ArrayStream
238238 , Streamly.FileSystem.Handle
239239
240240 , Streamly.Tutorial
test/Arrays.hs+3−4
@@ -12,7 +12,6 @@ import Test.QuickCheck.Monadic (monadicIO, assert)
1212import Test.Hspec as H
1313
1414import qualified Streamly.Memory.Array as A
15−import qualified Streamly.Memory.ArrayStream as AS
1615import qualified Streamly.Prelude as S
1716
1817-- Coverage build takes too long with default number of tests
@@ -75,7 +74,7 @@ testArraysOf =
7574 monadicIO $ do
7675 xs <- S.toList
7776 $ S.concatMap A.read
78− $ AS.arraysOf 240
77+ $ A.arraysOf 240
7978 $ S.fromList list
8079 assert (xs == list)
8180
@@ -85,8 +84,8 @@ testFlattenArrays =
8584 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
8685 monadicIO $ do
8786 xs <- S.toList
88− $ AS.flatten
89− $ AS.arraysOf 240
87+ $ A.flatten
88+ $ A.arraysOf 240
9089 $ S.fromList list
9190 assert (xs == list)
9291
test/String.hs+1−2
@@ -13,7 +13,6 @@ import Test.QuickCheck.Monadic (run, monadicIO, assert)
1313import Test.Hspec as H
1414
1515import qualified Streamly.Memory.Array as A
16−import qualified Streamly.Memory.ArrayStream as AS
1716import qualified Streamly.Prelude as S
1817import qualified Streamly.Data.String as SS
1918
@@ -58,7 +57,7 @@ testLinesArray =
5857 monadicIO $ do
5958 xs <- S.toList
6059 $ S.map A.toList
61− $ AS.splitOn 10
60+ $ A.splitOn 10
6261 $ S.yield (A.fromList list)
6362 assert (xs == map (map (fromIntegral . ord))
6463 (lines (map (chr . fromIntegral) list)))