@@ -115,7 +115,7 @@ import Prelude hiding (read)
116import qualified System.IO as SIO
116import qualified System.IO as SIO
118−import Streamly.Memory.Array.Types (Array(..))
118+import Streamly.Memory.Array.Types (Array(..), defaultChunkSize)
119import Streamly.Streams.Serial (SerialT)
119import Streamly.Streams.Serial (SerialT)
120import Streamly.Streams.StreamK.Type (IsStream)
120import Streamly.Streams.StreamK.Type (IsStream)
121import Streamly.SVar (MonadAsync)
121import Streamly.SVar (MonadAsync)
@@ -123,8 +123,7 @@ import Streamly.SVar (MonadAsync)
123-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
123-- import Streamly.String (encodeUtf8, decodeUtf8, foldLines)
125import qualified Streamly.FileSystem.Handle as FH
125import qualified Streamly.FileSystem.Handle as FH
126−import qualified Streamly.Memory.ArrayStream as AS
126+import qualified Streamly.Memory.Array as A
127−import qualified Streamly.Memory.Array.Types as A hiding (flattenArrays)
128import qualified Streamly.Prelude as S
127import qualified Streamly.Prelude as S
130-------------------------------------------------------------------------------
129-------------------------------------------------------------------------------
@@ -203,7 +202,7 @@ readArraysOf size file = withFile file ReadMode (FH.readArraysOf size)
203{-# INLINE readArrays #-}
202{-# INLINE readArrays #-}
204readArrays :: (IsStream t, MonadCatch m, MonadIO m)
203readArrays :: (IsStream t, MonadCatch m, MonadIO m)
205 => FilePath -> t m (Array Word8)
204 => FilePath -> t m (Array Word8)
206−readArrays = readArraysOf A.defaultChunkSize
205+readArrays = readArraysOf defaultChunkSize
208-------------------------------------------------------------------------------
207-------------------------------------------------------------------------------
209-- Read File to Stream
208-- Read File to Stream
@@ -226,7 +225,7 @@ readInChunksOf chunkSize h = A.flattenArrays $ readArraysOf chunkSize h
227-- read :: (IsStream t, MonadIO m, Storable a) => Handle -> t m a
226-- read :: (IsStream t, MonadIO m, Storable a) => Handle -> t m a
229−-- > read = 'readByChunks' A.defaultChunkSize
228+-- > read = 'readByChunks' defaultChunkSize
230-- | Generate a stream of elements of the given type from a file specified by
229-- | Generate a stream of elements of the given type from a file specified by
231-- path. The stream ends when EOF is encountered. File is locked using multiple
230-- path. The stream ends when EOF is encountered. File is locked using multiple
232-- reader and single writer locking mode.
231-- reader and single writer locking mode.
@@ -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 = AS.flatten $ withFile file ReadMode FH.readArrays
236+read file = A.concat $ withFile file ReadMode FH.readArrays
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
@@ -290,9 +289,9 @@ writeArrays = writeArraysMode WriteMode
290{-# INLINE writeInChunksOf #-}
289{-# INLINE writeInChunksOf #-}
291writeInChunksOf :: (MonadAsync m, MonadCatch m)
290writeInChunksOf :: (MonadAsync m, MonadCatch m)
292 => Int -> FilePath -> SerialT m Word8 -> m ()
291 => Int -> FilePath -> SerialT m Word8 -> m ()
293−writeInChunksOf n file xs = writeArrays file $ AS.arraysOf n xs
292+writeInChunksOf n file xs = writeArrays file $ A.arraysOf n xs
295−-- > write = 'writeInChunksOf' A.defaultChunkSize
294+-- > write = 'writeInChunksOf' defaultChunkSize
297-- | Write a byte stream to a file. Combines the bytes in chunks of size
296-- | Write a byte stream to a file. Combines the bytes in chunks of size
298-- up to 'A.defaultChunkSize' before writing. If the file exists it is
297-- up to 'A.defaultChunkSize' before writing. If the file exists it is
@@ -302,7 +301,7 @@ writeInChunksOf n file xs = writeArrays file $ AS.arraysOf n xs
302-- @since 0.7.0
301-- @since 0.7.0
303{-# INLINE write #-}
302{-# INLINE write #-}
304write :: (MonadAsync m, MonadCatch m) => FilePath -> SerialT m Word8 -> m ()
303write :: (MonadAsync m, MonadCatch m) => FilePath -> SerialT m Word8 -> m ()
305−write = writeInChunksOf A.defaultChunkSize
304+write = writeInChunksOf defaultChunkSize
308{-# INLINE write #-}
307{-# INLINE write #-}
@@ -326,7 +325,7 @@ appendArrays = writeArraysMode AppendMode
326{-# INLINE appendByChunks #-}
325{-# INLINE appendByChunks #-}
327appendByChunks :: (MonadAsync m, MonadCatch m)
326appendByChunks :: (MonadAsync m, MonadCatch m)
328 => Int -> FilePath -> SerialT m Word8 -> m ()
327 => Int -> FilePath -> SerialT m Word8 -> m ()
329−appendByChunks n file xs = appendArrays file $ AS.arraysOf n xs
328+appendByChunks n file xs = appendArrays file $ A.arraysOf n xs
331-- | Append a byte stream to a file. Combines the bytes in chunks of size up to
330-- | Append a byte stream to a file. Combines the bytes in chunks of size up to
332-- 'A.defaultChunkSize' before writing. If the file exists then the new data
331-- 'A.defaultChunkSize' before writing. If the file exists then the new data
@@ -336,7 +335,7 @@ appendByChunks n file xs = appendArrays file $ AS.arraysOf n xs
336-- @since 0.7.0
335-- @since 0.7.0
337{-# INLINE append #-}
336{-# INLINE append #-}
338append :: (MonadAsync m, MonadCatch m) => FilePath -> SerialT m Word8 -> m ()
337append :: (MonadAsync m, MonadCatch m) => FilePath -> SerialT m Word8 -> m ()
339−append = appendByChunks A.defaultChunkSize
338+append = appendByChunks defaultChunkSize
342-- | Like 'append' but the file is not locked for exclusive writes.
341-- | Like 'append' but the file is not locked for exclusive writes.
@@ -461,7 +460,7 @@ readSliceWith chunkSize h pos len = undefined
461{-# INLINE readSlice #-}
460{-# INLINE readSlice #-}
462readSlice :: (IsStream t, MonadIO m, Storable a)
461readSlice :: (IsStream t, MonadIO m, Storable a)
463 => Handle -> Int -> Int -> t m a
462 => Handle -> Int -> Int -> t m a
464−readSlice = readSliceWith A.defaultChunkSize
463+readSlice = readSliceWith defaultChunkSize
466-- | @readSliceRev h i count@ streams a slice from the file handle @h@ starting
465-- | @readSliceRev h i count@ streams a slice from the file handle @h@ starting
467-- at index @i@ and reading up to @count@ elements in the reverse direction
466-- at index @i@ and reading up to @count@ elements in the reverse direction