on master help sign in
Hide some array stream combinators
1c339acHarendra Kumar
src/Streamly/Data/String.hs+2−1
@@ -93,6 +93,7 @@ import Streamly.Unfold (Unfold)
93import qualified Streamly.Prelude.Internal as S
93import qualified Streamly.Prelude.Internal as S
94import qualified Streamly.Memory.Array as A
94import qualified Streamly.Memory.Array as A
95import qualified Streamly.Memory.Array.Types as A
95import qualified Streamly.Memory.Array.Types as A
96+import qualified Streamly.Memory.ArrayStream as AS
96import qualified Streamly.Streams.StreamD as D
97import qualified Streamly.Streams.StreamD as D
97import qualified Streamly.Unfold as UF
98import qualified Streamly.Unfold as UF
98
99
@@ -288,4 +289,4 @@ unlines = unfoldLines A.readU
288-- > unwords . words /= id
289-- > unwords . words /= id
289{-# INLINE unwords #-}
290{-# INLINE unwords #-}
290unwords :: (MonadAsync m, IsStream t) => t m (Array Char) -> t m Char
291unwords :: (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
326--
326--
327{-# INLINE readInChunksOf #-}
327{-# INLINE readInChunksOf #-}
328readInChunksOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m Word8
328readInChunksOf :: (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
330
330
331-- TODO
331-- TODO
332-- read :: (IsStream t, MonadIO m, Storable a) => Handle -> t m a
332-- read :: (IsStream t, MonadIO m, Storable a) => Handle -> t m a
@@ -338,7 +338,7 @@ readInChunksOf chunkSize h = A.concat $ readArraysOfUpto chunkSize h
338-- @since 0.7.0
338-- @since 0.7.0
339{-# INLINE read #-}
339{-# INLINE read #-}
340read :: (IsStream t, MonadIO m) => Handle -> t m Word8
340read :: (IsStream t, MonadIO m) => Handle -> t m Word8
341−read = A.concat . readArrays
341+read = AS.concat . readArrays
342
342
343-------------------------------------------------------------------------------
343-------------------------------------------------------------------------------
344-- Writing
344-- Writing
@@ -360,7 +360,7 @@ writeArrays h m = S.mapM_ (liftIO . writeArray h) m
360{-# INLINE writeArraysPackedUpto #-}
360{-# INLINE writeArraysPackedUpto #-}
361writeArraysPackedUpto :: (MonadIO m, Storable a)
361writeArraysPackedUpto :: (MonadIO m, Storable a)
362 => Int -> Handle -> SerialT m (Array a) -> m ()
362 => 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
364
364
365#if !defined(mingw32_HOST_OS)
365#if !defined(mingw32_HOST_OS)
366-- XXX this is incomplete
366-- XXX this is incomplete
src/Streamly/FileSystem/File.hs+1−2
@@ -123,7 +123,6 @@ import Streamly.SVar (MonadAsync)
123-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
123-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
124
124
125import qualified Streamly.FileSystem.Handle as FH
125import qualified Streamly.FileSystem.Handle as FH
126−import qualified Streamly.Memory.Array as A
127import qualified Streamly.Memory.ArrayStream as AS
126import qualified Streamly.Memory.ArrayStream as AS
128import qualified Streamly.Prelude as S
127import qualified Streamly.Prelude as S
129
128
@@ -234,7 +233,7 @@ readInChunksOf chunkSize h = A.flattenArrays $ readArraysOf chunkSize h
234-- @since 0.7.0
233-- @since 0.7.0
235{-# INLINE read #-}
234{-# INLINE read #-}
236read :: (IsStream t, MonadCatch m, MonadIO m) => FilePath -> t m Word8
235read :: (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
238
237
239{-
238{-
240-- | Generate a stream of elements of the given type from a file 'Handle'. The
239-- | 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)
129import qualified Streamly.Fold as FL
129import qualified Streamly.Fold as FL
130import qualified Streamly.Fold.Types as FL
130import qualified Streamly.Fold.Types as FL
131import qualified Streamly.Memory.Array as A
131import qualified Streamly.Memory.Array as A
132+import qualified Streamly.Memory.ArrayStream as AS
132import qualified Streamly.Streams.StreamD.Type as D
133import qualified Streamly.Streams.StreamD.Type as D
133
134
134-------------------------------------------------------------------------------
135-------------------------------------------------------------------------------
@@ -231,7 +232,7 @@ readArrays = readArraysOf defaultChunkSize
231-- @since 0.7.0
232-- @since 0.7.0
232{-# INLINE readInChunksOf #-}
233{-# INLINE readInChunksOf #-}
233readInChunksOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m Word8
234readInChunksOf :: (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
235
236
236-- TODO
237-- TODO
237-- Generate a stream of elements of the given type from a file 'Handle'.
238-- 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
243-- @since 0.7.0
244-- @since 0.7.0
244{-# INLINE read #-}
245{-# INLINE read #-}
245read :: (IsStream t, MonadIO m) => Handle -> t m Word8
246read :: (IsStream t, MonadIO m) => Handle -> t m Word8
246−read = A.concat . readArrays
247+read = AS.concat . readArrays
247
248
248-------------------------------------------------------------------------------
249-------------------------------------------------------------------------------
249-- Writing
250-- Writing
src/Streamly/Memory/Array.hs+4−4
@@ -125,14 +125,14 @@ module Streamly.Memory.Array
125 -- -- ** Creation
125 -- -- ** Creation
126 -- , AS.arraysOf
126 -- , AS.arraysOf
127
127
128− -- ** Elimination
128+ -- -- ** Elimination
129− , AS.concat
129+ -- , AS.concat
130 -- , AS.concatRev
130 -- , AS.concatRev
131− , AS.toArray
131+ -- , AS.toArray
132
132
133 -- ** Transformation
133 -- ** Transformation
134 , AS.splitOn
134 , AS.splitOn
135− , AS.compact -- compact
135+ -- , AS.compact -- compact
136 )
136 )
137where
137where
138
138
src/Streamly/Network/Client.hs+2−2
@@ -72,7 +72,7 @@ import Streamly.Memory.Array.Types (Array(..), defaultChunkSize, writeNUnsafe)
72import Streamly.Streams.StreamK.Type (IsStream)
72import Streamly.Streams.StreamK.Type (IsStream)
73
73
74import qualified Streamly.Fold.Types as FL
74import qualified Streamly.Fold.Types as FL
75−import qualified Streamly.Memory.Array as A
75+import qualified Streamly.Memory.ArrayStream as AS
76import qualified Streamly.Prelude as S
76import qualified Streamly.Prelude as S
77import qualified Streamly.Network.Socket as SK
77import qualified Streamly.Network.Socket as SK
78
78
@@ -110,7 +110,7 @@ withConnection addr port =
110{-# INLINE read #-}
110{-# INLINE read #-}
111read :: (IsStream t, MonadCatch m, MonadIO m)
111read :: (IsStream t, MonadCatch m, MonadIO m)
112 => (Word8, Word8, Word8, Word8) -> PortNumber -> t m Word8
112 => (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
114
114
115-------------------------------------------------------------------------------
115-------------------------------------------------------------------------------
116-- Writing
116-- Writing
src/Streamly/Network/Socket.hs+1−1
@@ -266,7 +266,7 @@ readInChunksOf chunkSize h = A.flattenArrays $ readArraysUpto chunkSize h
266-- @since 0.7.0
266-- @since 0.7.0
267{-# INLINE read #-}
267{-# INLINE read #-}
268read :: (IsStream t, MonadIO m) => Socket -> t m Word8
268read :: (IsStream t, MonadIO m) => Socket -> t m Word8
269−read = A.concat . readArrays
269+read = AS.concat . readArrays
270
270
271-------------------------------------------------------------------------------
271-------------------------------------------------------------------------------
272-- Writing
272-- Writing
test/Arrays.hs+1−1
@@ -85,7 +85,7 @@ testFlattenArrays =
85 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
85 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
86 monadicIO $ do
86 monadicIO $ do
87 xs <- S.toList
87 xs <- S.toList
88− $ A.concat
88+ $ Internal.concatMapU Internal.readU
89 $ Internal.arraysOf 240
89 $ Internal.arraysOf 240
90 $ S.fromList list
90 $ S.fromList list
91 assert (xs == list)
91 assert (xs == list)