@@ -61,13 +61,13 @@ module Streamly.FileSystem.Handle
61 -- , readUtf8
61 -- , readUtf8
62 -- , readLines
62 -- , readLines
63 -- , readFrames
63 -- , readFrames
64− , readByChunksUpto
64+ , readInChunksOf
66 -- -- * Array Read
66 -- -- * Array Read
67 -- , readArrayUpto
67 -- , readArrayUpto
68 -- , readArrayOf
68 -- , readArrayOf
70− , readArraysOfUpto
70+ , readArraysOf
71 -- , readArraysOf
71 -- , readArraysOf
72 , readArrays
72 , readArrays
@@ -81,7 +81,7 @@ module Streamly.FileSystem.Handle
81 -- , writeUtf8
81 -- , writeUtf8
82 -- , writeUtf8ByLines
82 -- , writeUtf8ByLines
83 -- , writeByFrames
83 -- , writeByFrames
84− , writeByChunksOf
84+ , writeInChunksOf
86 -- -- * Array Write
86 -- -- * Array Write
87 , writeArray
87 , writeArray
@@ -187,13 +187,13 @@ writeArray h Array{..} = withForeignPtr aStart $ \p -> hPutBuf h p aLen
187-- Stream of Arrays IO
187-- Stream of Arrays IO
188-------------------------------------------------------------------------------
188-------------------------------------------------------------------------------
190−-- | @readArraysOfUpto size h@ reads a stream of arrays from file handle @h@.
190+-- | @readArraysOf size h@ reads a stream of arrays from file handle @h@.
191-- The maximum size of a single array is specified by @size@. The actual size
191-- The maximum size of a single array is specified by @size@. The actual size
192-- read may be less than or equal to @size@.
192-- read may be less than or equal to @size@.
193−{-# INLINABLE _readArraysOfUpto #-}
193+{-# INLINABLE _readArraysOf #-}
194−_readArraysOfUpto :: (IsStream t, MonadIO m)
194+_readArraysOf :: (IsStream t, MonadIO m)
195 => Int -> Handle -> t m (Array Word8)
195 => Int -> Handle -> t m (Array Word8)
196−_readArraysOfUpto size h = go
196+_readArraysOf size h = go
198 -- XXX use cons/nil instead
198 -- XXX use cons/nil instead
199 go = mkStream $ \_ yld _ stp -> do
199 go = mkStream $ \_ yld _ stp -> do
@@ -202,13 +202,14 @@ _readArraysOfUpto size h = go
203 else yld arr go
203 else yld arr go
205−-- | @readArraysOfUpto size handle@ reads a stream of arrays from the file
205+-- | @readArraysOf size handle@ reads a stream of arrays from the file
206-- handle @handle@. The maximum size of a single array is limited to @size@.
206-- handle @handle@. The maximum size of a single array is limited to @size@.
207+-- The actual size read may be less than or equal to @size@.
208-- @since 0.7.0
209-- @since 0.7.0
209−{-# INLINE_NORMAL readArraysOfUpto #-}
210+{-# INLINE_NORMAL readArraysOf #-}
210−readArraysOfUpto :: (IsStream t, MonadIO m) => Int -> Handle -> t m (Array Word8)
211+readArraysOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m (Array Word8)
211−readArraysOfUpto size h = D.fromStreamD (D.Stream step ())
212+readArraysOf size h = D.fromStreamD (D.Stream step ())
213 {-# INLINE_LATE step #-}
214 {-# INLINE_LATE step #-}
214 step _ _ = do
215 step _ _ = do
@@ -222,14 +223,15 @@ readArraysOfUpto size h = D.fromStreamD (D.Stream step ())
223-- | @readArrays handle@ reads a stream of arrays from the specified file
224-- | @readArrays handle@ reads a stream of arrays from the specified file
224-- handle. The maximum size of a single array is limited to
225-- handle. The maximum size of a single array is limited to
226+-- @defaultChunkSize@. The actual size read may be less than or equal to
225-- @defaultChunkSize@.
227-- @defaultChunkSize@.
227−-- > readArrays = readArraysOfUpto defaultChunkSize
229+-- > readArrays = readArraysOf defaultChunkSize
229-- @since 0.7.0
231-- @since 0.7.0
230{-# INLINE readArrays #-}
232{-# INLINE readArrays #-}
231readArrays :: (IsStream t, MonadIO m) => Handle -> t m (Array Word8)
233readArrays :: (IsStream t, MonadIO m) => Handle -> t m (Array Word8)
232−readArrays = readArraysOfUpto defaultChunkSize
234+readArrays = readArraysOf defaultChunkSize
234-------------------------------------------------------------------------------
236-------------------------------------------------------------------------------
235-- Read File to Stream
237-- Read File to Stream
@@ -239,13 +241,13 @@ readArrays = readArraysOfUpto defaultChunkSize
239-- read requests at the same time. For serial case we can use async IO. We can
241-- read requests at the same time. For serial case we can use async IO. We can
240-- also control the read throughput in mbps or IOPS.
242-- also control the read throughput in mbps or IOPS.
242−-- | @readByChunksUpto chunkSize handle@ reads a byte stream from a file
244+-- | @readInChunksOf chunkSize handle@ reads a byte stream from a file
243-- handle, reads are performed in chunks of up to @chunkSize@.
245-- handle, reads are performed in chunks of up to @chunkSize@.
245-- @since 0.7.0
247-- @since 0.7.0
246−{-# INLINE readByChunksUpto #-}
248+{-# INLINE readInChunksOf #-}
247−readByChunksUpto :: (IsStream t, MonadIO m) => Int -> Handle -> t m Word8
249+readInChunksOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m Word8
248−readByChunksUpto chunkSize h = AS.flatten $ readArraysOfUpto chunkSize h
250+readInChunksOf chunkSize h = AS.flatten $ readArraysOf chunkSize h
251-- Generate a stream of elements of the given type from a file 'Handle'.
253-- Generate a stream of elements of the given type from a file 'Handle'.
@@ -289,16 +291,16 @@ writeArraysPackedUpto n h xs = writeArrays h $ AS.compact n xs
289-- do not want buffering to occur at GHC level as well. Same thing applies to
291-- do not want buffering to occur at GHC level as well. Same thing applies to
290-- writes as well.
292-- writes as well.
292−-- | @writeByChunksOf chunkSize handle stream@ writes @stream@ to @handle@ in
294+-- | @writeInChunksOf chunkSize handle stream@ writes @stream@ to @handle@ in
293-- chunks of @chunkSize@. A write is performed to the IO device as soon as we
295-- chunks of @chunkSize@. A write is performed to the IO device as soon as we
294-- collect the required input size.
296-- collect the required input size.
296-- @since 0.7.0
298-- @since 0.7.0
297−{-# INLINE writeByChunksOf #-}
299+{-# INLINE writeInChunksOf #-}
298−writeByChunksOf :: MonadIO m => Int -> Handle -> SerialT m Word8 -> m ()
300+writeInChunksOf :: MonadIO m => Int -> Handle -> SerialT m Word8 -> m ()
299−writeByChunksOf n h m = writeArrays h $ AS.arraysOf n m
301+writeInChunksOf n h m = writeArrays h $ AS.arraysOf n m
301−-- > write = 'writeByChunksOf' A.defaultChunkSize
303+-- > write = 'writeInChunksOf' A.defaultChunkSize
303-- | Write a byte stream to a file handle. Combines the bytes in chunks of
305-- | Write a byte stream to a file handle. Combines the bytes in chunks of
304-- up to 'A.defaultChunkSize' before writing.
306-- up to 'A.defaultChunkSize' before writing.
@@ -306,7 +308,7 @@ writeByChunksOf n h m = writeArrays h $ AS.arraysOf n m
306-- @since 0.7.0
308-- @since 0.7.0
307{-# INLINE write #-}
309{-# INLINE write #-}
308write :: MonadIO m => Handle -> SerialT m Word8 -> m ()
310write :: MonadIO m => Handle -> SerialT m Word8 -> m ()
309−write = writeByChunksOf defaultChunkSize
311+write = writeInChunksOf defaultChunkSize
312{-# INLINE write #-}
314{-# INLINE write #-}