on master help sign in
Hide some array stream combinators

* Those that can already be expressed in terms of streams * Those that are not used anywhere, if needed they can be expressed in terms of * streams.

commit1c339acfc68c2424d809b73c9d135c7b3f4a8276 authorHarendra Kumar <harendra.kumar@gmail.com> dateFri 13 Sep 2019, 14:02 (7 years ago) parent006fc5f
8 files changed+17−16
src/Streamly/Data/String.hs+2−1 src/Streamly/FileSystem/FD.hs+3−3 src/Streamly/FileSystem/File.hs+1−2 src/Streamly/FileSystem/Handle.hs+3−2 src/Streamly/Memory/Array.hs+4−4 src/Streamly/Network/Client.hs+2−2 src/Streamly/Network/Socket.hs+1−1 test/Arrays.hs+1−1
src/Streamly/Data/String.hs+2−1
@@ -93,6 +93,7 @@ import Streamly.Unfold (Unfold)
9393import qualified Streamly.Prelude.Internal as S
9494import qualified Streamly.Memory.Array as A
9595import qualified Streamly.Memory.Array.Types as A
96+import qualified Streamly.Memory.ArrayStream as AS
9697import qualified Streamly.Streams.StreamD as D
9798import qualified Streamly.Unfold as UF
9899
@@ -288,4 +289,4 @@ unlines = unfoldLines A.readU
288289-- > unwords . words /= id
289290{-# INLINE unwords #-}
290291unwords :: (MonadAsync m, IsStream t) => t m (Array Char) -> t m Char
291−unwords = A.concat . (S.intersperse (A.fromList " "))
292+unwords = AS.concat . (S.intersperse (A.fromList " "))
src/Streamly/FileSystem/FD.hs+3−3
@@ -326,7 +326,7 @@ readArrays = readArraysOfUpto defaultChunkSize
326326--
327327{-# INLINE readInChunksOf #-}
328328readInChunksOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m Word8
329−readInChunksOf chunkSize h = A.concat $ readArraysOfUpto chunkSize h
329+readInChunksOf chunkSize h = AS.concat $ readArraysOfUpto chunkSize h
330330
331331-- TODO
332332-- read :: (IsStream t, MonadIO m, Storable a) => Handle -> t m a
@@ -338,7 +338,7 @@ readInChunksOf chunkSize h = A.concat $ readArraysOfUpto chunkSize h
338338-- @since 0.7.0
339339{-# INLINE read #-}
340340read :: (IsStream t, MonadIO m) => Handle -> t m Word8
341−read = A.concat . readArrays
341+read = AS.concat . readArrays
342342
343343-------------------------------------------------------------------------------
344344-- Writing
@@ -360,7 +360,7 @@ writeArrays h m = S.mapM_ (liftIO . writeArray h) m
360360{-# INLINE writeArraysPackedUpto #-}
361361writeArraysPackedUpto :: (MonadIO m, Storable a)
362362 => Int -> Handle -> SerialT m (Array a) -> m ()
363−writeArraysPackedUpto n h xs = writeArrays h $ A.compact n xs
363+writeArraysPackedUpto n h xs = writeArrays h $ AS.compact n xs
364364
365365#if !defined(mingw32_HOST_OS)
366366-- XXX this is incomplete
src/Streamly/FileSystem/File.hs+1−2
@@ -123,7 +123,6 @@ import Streamly.SVar (MonadAsync)
123123-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
124124
125125import qualified Streamly.FileSystem.Handle as FH
126−import qualified Streamly.Memory.Array as A
127126import qualified Streamly.Memory.ArrayStream as AS
128127import qualified Streamly.Prelude as S
129128
@@ -234,7 +233,7 @@ readInChunksOf chunkSize h = A.flattenArrays $ readArraysOf chunkSize h
234233-- @since 0.7.0
235234{-# INLINE read #-}
236235read :: (IsStream t, MonadCatch m, MonadIO m) => FilePath -> t m Word8
237−read file = A.concat $ withFile file ReadMode FH.readArrays
236+read file = AS.concat $ withFile file ReadMode FH.readArrays
238237
239238{-
240239-- | Generate a stream of elements of the given type from a file 'Handle'. The
src/Streamly/FileSystem/Handle.hs+3−2
@@ -129,6 +129,7 @@ import Streamly.Fold (Fold)
129129import qualified Streamly.Fold as FL
130130import qualified Streamly.Fold.Types as FL
131131import qualified Streamly.Memory.Array as A
132+import qualified Streamly.Memory.ArrayStream as AS
132133import qualified Streamly.Streams.StreamD.Type as D
133134
134135-------------------------------------------------------------------------------
@@ -231,7 +232,7 @@ readArrays = readArraysOf defaultChunkSize
231232-- @since 0.7.0
232233{-# INLINE readInChunksOf #-}
233234readInChunksOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m Word8
234−readInChunksOf chunkSize h = A.concat $ readArraysOf chunkSize h
235+readInChunksOf chunkSize h = AS.concat $ readArraysOf chunkSize h
235236
236237-- TODO
237238-- Generate a stream of elements of the given type from a file 'Handle'.
@@ -243,7 +244,7 @@ readInChunksOf chunkSize h = A.concat $ readArraysOf chunkSize h
243244-- @since 0.7.0
244245{-# INLINE read #-}
245246read :: (IsStream t, MonadIO m) => Handle -> t m Word8
246−read = A.concat . readArrays
247+read = AS.concat . readArrays
247248
248249-------------------------------------------------------------------------------
249250-- Writing
src/Streamly/Memory/Array.hs+4−4
@@ -125,14 +125,14 @@ module Streamly.Memory.Array
125125 -- -- ** Creation
126126 -- , AS.arraysOf
127127
128− -- ** Elimination
129− , AS.concat
128+ -- -- ** Elimination
129+ -- , AS.concat
130130 -- , AS.concatRev
131− , AS.toArray
131+ -- , AS.toArray
132132
133133 -- ** Transformation
134134 , AS.splitOn
135− , AS.compact -- compact
135+ -- , AS.compact -- compact
136136 )
137137where
138138
src/Streamly/Network/Client.hs+2−2
@@ -72,7 +72,7 @@ import Streamly.Memory.Array.Types (Array(..), defaultChunkSize, writeNUnsafe)
7272import Streamly.Streams.StreamK.Type (IsStream)
7373
7474import qualified Streamly.Fold.Types as FL
75−import qualified Streamly.Memory.Array as A
75+import qualified Streamly.Memory.ArrayStream as AS
7676import qualified Streamly.Prelude as S
7777import qualified Streamly.Network.Socket as SK
7878
@@ -110,7 +110,7 @@ withConnection addr port =
110110{-# INLINE read #-}
111111read :: (IsStream t, MonadCatch m, MonadIO m)
112112 => (Word8, Word8, Word8, Word8) -> PortNumber -> t m Word8
113−read addr port = A.concat $ withConnection addr port SK.readArrays
113+read addr port = AS.concat $ withConnection addr port SK.readArrays
114114
115115-------------------------------------------------------------------------------
116116-- Writing
src/Streamly/Network/Socket.hs+1−1
@@ -266,7 +266,7 @@ readInChunksOf chunkSize h = A.flattenArrays $ readArraysUpto chunkSize h
266266-- @since 0.7.0
267267{-# INLINE read #-}
268268read :: (IsStream t, MonadIO m) => Socket -> t m Word8
269−read = A.concat . readArrays
269+read = AS.concat . readArrays
270270
271271-------------------------------------------------------------------------------
272272-- Writing
test/Arrays.hs+1−1
@@ -85,7 +85,7 @@ testFlattenArrays =
8585 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
8686 monadicIO $ do
8787 xs <- S.toList
88− $ A.concat
88+ $ Internal.concatMapU Internal.readU
8989 $ Internal.arraysOf 240
9090 $ S.fromList list
9191 assert (xs == list)