@@ -11,13 +11,13 @@
12-- The fundamental singleton IO APIs are 'getChunk' and 'putChunk' and the
12-- The fundamental singleton IO APIs are 'getChunk' and 'putChunk' and the
13-- fundamental stream IO APIs built on top of those are
13-- fundamental stream IO APIs built on top of those are
14−-- 'readChunksWithBufferOf' and 'writeChunks'. Rest of this module is just
14+-- 'readChunksWith' and 'writeChunks'. Rest of this module is just
15-- combinatorial programming using these.
15-- combinatorial programming using these.
17-- We can achieve line buffering by folding lines in the input stream into a
17-- We can achieve line buffering by folding lines in the input stream into a
18-- stream of arrays using Stream.splitOn or Fold.takeEndBy_ and similar
18-- stream of arrays using Stream.splitOn or Fold.takeEndBy_ and similar
19-- operations. One can wrap the input stream in 'Maybe' type and then use
19-- operations. One can wrap the input stream in 'Maybe' type and then use
20−-- 'writeMaybesWithBufferOf' to achieve user controlled buffering.
20+-- 'writeMaybesWith' to achieve user controlled buffering.
22-- TODO: Need a separate module for pread/pwrite based reading writing for
22-- TODO: Need a separate module for pread/pwrite based reading writing for
23-- seekable devices. Stateless read/write can be helpful in multithreaded
23-- seekable devices. Stateless read/write can be helpful in multithreaded
@@ -35,17 +35,17 @@ module Streamly.Internal.FileSystem.Handle
35 -- , readUtf8
35 -- , readUtf8
36 -- , readLines
36 -- , readLines
37 -- , readFrames
37 -- , readFrames
38− , readWithBufferOf
38+ , readWith
40− , toBytes
40+ , getBytes
41− , toBytesWithBufferOf
41+ , getBytesWith
43 -- * Chunked Stream Read
43 -- * Chunked Stream Read
44 , readChunks
44 , readChunks
45− , readChunksWithBufferOf
45+ , readChunksWith
47− , toChunksWithBufferOf
47+ , getChunksWith
48− , toChunks
48+ , getChunks
50 -- * Byte Stream Write
50 -- * Byte Stream Write
51 -- Byte stream write (Folds)
51 -- Byte stream write (Folds)
@@ -55,17 +55,17 @@ module Streamly.Internal.FileSystem.Handle
55 -- , writeUtf8ByLines
55 -- , writeUtf8ByLines
56 -- , writeByFrames
56 -- , writeByFrames
57 -- , writeLines
57 -- , writeLines
58− , writeWithBufferOf
58+ , writeWith
59− , writeMaybesWithBufferOf
59+ , writeMaybesWith
61 , putBytes
61 , putBytes
62− , putBytesWithBufferOf
62+ , putBytesWith
64 -- * Chunked Stream Write
64 -- * Chunked Stream Write
65 , writeChunks
65 , writeChunks
66− , writeChunksWithBufferOf
66+ , writeChunksWith
68− , putChunksWithBufferOf
68+ , putChunksWith
69 , putChunks
69 , putChunks
71 -- * Random Access (Seek)
71 -- * Random Access (Seek)
@@ -101,6 +101,11 @@ module Streamly.Internal.FileSystem.Handle
101 -- , writeChunksFromTo
101 -- , writeChunksFromTo
102 -- , writeChunksFromToWith
102 -- , writeChunksFromToWith
103 -- , writeChunksFromThenToWith
103 -- , writeChunksFromThenToWith
105+ , readChunksWithBufferOf
107+ , writeChunksWithBufferOf
@@ -203,13 +208,14 @@ getChunkOf = undefined
203-- Stream of Arrays IO
208-- Stream of Arrays IO
204-------------------------------------------------------------------------------
209-------------------------------------------------------------------------------
206−-- | @toChunksWithBufferOf size h@ reads a stream of arrays from file handle @h@.
211+-- | @getChunksWith size h@ reads a stream of arrays from file handle @h@.
207-- The maximum size of a single array is specified by @size@. The actual size
212-- The maximum size of a single array is specified by @size@. The actual size
208-- read may be less than or equal to @size@.
213-- read may be less than or equal to @size@.
209−{-# INLINE _toChunksWithBufferOf #-}
214+-- @since 0.9.0
215+{-# INLINE _getChunksWith #-}
210−_toChunksWithBufferOf :: (IsStream t, MonadIO m)
216+_getChunksWith :: (IsStream t, MonadIO m)
211 => Int -> Handle -> t m (Array Word8)
217 => Int -> Handle -> t m (Array Word8)
212−_toChunksWithBufferOf size h = go
218+_getChunksWith size h = go
214 -- XXX use cons/nil instead
220 -- XXX use cons/nil instead
215 go = mkStream $ \_ yld _ stp -> do
221 go = mkStream $ \_ yld _ stp -> do
@@ -218,22 +224,17 @@ _toChunksWithBufferOf size h = go
219 else yld arr go
225 else yld arr go
221−-- | @toChunksWithBufferOf size handle@ reads a stream of arrays from the file
227+-- | @getChunksWith size handle@ reads a stream of arrays from the file
222-- handle @handle@. The maximum size of a single array is limited to @size@.
228-- handle @handle@. The maximum size of a single array is limited to @size@.
223-- The actual size read may be less than or equal to @size@.
229-- The actual size read may be less than or equal to @size@.
225−-- >>> toChunksWithBufferOf size h = Stream.unfold Handle.readChunksWithBufferOf (size, h)
231+-- >>> getChunksWith size h = Stream.unfold Handle.readChunksWith (size, h)
227−-- @since 0.7.0
233+-- @since 0.9.0
228−{-# INLINE_NORMAL toChunksWithBufferOf #-}
234+{-# INLINE_NORMAL getChunksWith #-}
229−toChunksWithBufferOf :: (IsStream t, MonadIO m) =>
235+getChunksWith :: (IsStream t, MonadIO m) =>
230 Int -> Handle -> t m (Array Word8)
236 Int -> Handle -> t m (Array Word8)
232−toChunksWithBufferOf size h =
233− S.repeatM (getChunk size h)
234− & S.takeWhile ((/= 0) . byteLength)
236−toChunksWithBufferOf size h = fromStreamD (D.Stream step ())
237+getChunksWith size h = fromStreamD (D.Stream step ())
238 {-# INLINE_LATE step #-}
239 {-# INLINE_LATE step #-}
239 step _ _ = do
240 step _ _ = do
@@ -248,31 +249,27 @@ toChunksWithBufferOf size h = fromStreamD (D.Stream step ())
248-- @bufsize@. The size of an array in the resulting stream is always less than
249-- @bufsize@. The size of an array in the resulting stream is always less than
249-- or equal to @bufsize@.
250-- or equal to @bufsize@.
251−-- @since 0.7.0
252+-- @since 0.9.0
252−{-# INLINE_NORMAL readChunksWithBufferOf #-}
253+{-# INLINE_NORMAL readChunksWith #-}
253−readChunksWithBufferOf :: MonadIO m => Unfold m (Int, Handle) (Array Word8)
254+readChunksWith :: MonadIO m => Unfold m (Int, Handle) (Array Word8)
254−readChunksWithBufferOf =
255+readChunksWith =
255 UF.lmap (uncurry getChunk) UF.repeatM
256 UF.lmap (uncurry getChunk) UF.repeatM
256 & UF.takeWhile ((/= 0) . byteLength)
257 & UF.takeWhile ((/= 0) . byteLength)
258−readChunksWithBufferOf = Unfold step return
262− {-# INLINE_LATE step #-}
260+-- | Same as 'readChunksWith'
263− step (size, h) = do
261+--
264− arr <- getChunk size h
262+-- @since 0.7.0
265− return $
263+{-# DEPRECATED readChunksWithBufferOf "Please use readChunksWith instead." #-}
266− case byteLength arr of
264+{-# INLINE_NORMAL readChunksWithBufferOf #-}
267− 0 -> D.Stop
265+readChunksWithBufferOf :: MonadIO m => Unfold m (Int, Handle) (Array Word8)
268− _ -> D.Yield arr (size, h)
266+readChunksWithBufferOf = readChunksWith
271-- There are two ways to implement this.
268-- There are two ways to implement this.
273−-- 1. Idiomatic: use a scan on the output of readChunksWithBufferOf to total
270+-- 1. Idiomatic: use a scan on the output of readChunksWith to total
274-- the array lengths and trim the last array to correct size.
271-- the array lengths and trim the last array to correct size.
275−-- 2. Simply implement it from scratch like readChunksWithBufferOf.
272+-- 2. Simply implement it from scratch like readChunksWith.
277-- XXX Change this to readChunksWithFromTo (bufferSize, from, to, h)?
274-- XXX Change this to readChunksWithFromTo (bufferSize, from, to, h)?
@@ -305,19 +302,20 @@ readChunksFromToWith = Unfold step inject
305 assert (len <= remaining)
302 assert (len <= remaining)
306 $ D.Yield arr (remaining - len, bufSize, h)
303 $ D.Yield arr (remaining - len, bufSize, h)
308-- XXX read 'Array a' instead of Word8
306-- XXX read 'Array a' instead of Word8
310−-- | @toChunks handle@ reads a stream of arrays from the specified file
308+-- | @getChunks handle@ reads a stream of arrays from the specified file
311-- handle. The maximum size of a single array is limited to
309-- handle. The maximum size of a single array is limited to
312-- @defaultChunkSize@. The actual size read may be less than or equal to
310-- @defaultChunkSize@. The actual size read may be less than or equal to
313-- @defaultChunkSize@.
311-- @defaultChunkSize@.
315−-- >>> toChunks = Handle.toChunksWithBufferOf IO.defaultChunkSize
313+-- >>> getChunks = Handle.getChunksWith IO.defaultChunkSize
317−-- @since 0.7.0
315+-- @since 0.9.0
318−{-# INLINE toChunks #-}
316+{-# INLINE getChunks #-}
319−toChunks :: (IsStream t, MonadIO m) => Handle -> t m (Array Word8)
317+getChunks :: (IsStream t, MonadIO m) => Handle -> t m (Array Word8)
320−toChunks = toChunksWithBufferOf defaultChunkSize
318+getChunks = getChunksWith defaultChunkSize
322-- | Unfolds a handle into a stream of 'Word8' arrays. Requests to the IO
320-- | Unfolds a handle into a stream of 'Word8' arrays. Requests to the IO
323-- device are performed using a buffer of size
321-- device are performed using a buffer of size
@@ -325,12 +323,12 @@ toChunks = toChunksWithBufferOf defaultChunkSize
325-- size of arrays in the resulting stream are therefore less than or equal to
323-- size of arrays in the resulting stream are therefore less than or equal to
326-- 'Streamly.Internal.Data.Array.Foreign.Type.defaultChunkSize'.
324-- 'Streamly.Internal.Data.Array.Foreign.Type.defaultChunkSize'.
328−-- >>> readChunks = Unfold.supplyFirst IO.defaultChunkSize Handle.readChunksWithBufferOf
326+-- >>> readChunks = Unfold.supplyFirst IO.defaultChunkSize Handle.readChunksWith
330-- @since 0.7.0
328-- @since 0.7.0
331{-# INLINE readChunks #-}
329{-# INLINE readChunks #-}
332readChunks :: MonadIO m => Unfold m Handle (Array Word8)
330readChunks :: MonadIO m => Unfold m Handle (Array Word8)
333−readChunks = UF.supplyFirst defaultChunkSize readChunksWithBufferOf
331+readChunks = UF.supplyFirst defaultChunkSize readChunksWith
335-------------------------------------------------------------------------------
333-------------------------------------------------------------------------------
336-- Read File to Stream
334-- Read File to Stream
@@ -343,22 +341,30 @@ readChunks = UF.supplyFirst defaultChunkSize readChunksWithBufferOf
343-- | Unfolds the tuple @(bufsize, handle)@ into a byte stream, read requests
341-- | Unfolds the tuple @(bufsize, handle)@ into a byte stream, read requests
344-- to the IO device are performed using buffers of @bufsize@.
342-- to the IO device are performed using buffers of @bufsize@.
346−-- >>> readWithBufferOf = Unfold.many Array.read Handle.readChunksWithBufferOf
344+-- >>> readWith = Unfold.many Array.read Handle.readChunksWith
347+{-# INLINE readWith #-}
348+readWith :: MonadIO m => Unfold m (Int, Handle) Word8
349+readWith = UF.many A.read readChunksWith
351+-- | Same as 'readWith'
348-- @since 0.7.0
353-- @since 0.7.0
354+{-# DEPRECATED readWithBufferOf "Please use readWith instead." #-}
349{-# INLINE readWithBufferOf #-}
355{-# INLINE readWithBufferOf #-}
350readWithBufferOf :: MonadIO m => Unfold m (Int, Handle) Word8
356readWithBufferOf :: MonadIO m => Unfold m (Int, Handle) Word8
351−readWithBufferOf = UF.many A.read readChunksWithBufferOf
357+readWithBufferOf = readWith
353−-- | @toBytesWithBufferOf bufsize handle@ reads a byte stream from a file
359+-- | @getBytesWith bufsize handle@ reads a byte stream from a file
354-- handle, reads are performed in chunks of up to @bufsize@.
360-- handle, reads are performed in chunks of up to @bufsize@.
356−-- >>> toBytesWithBufferOf size h = Stream.unfoldMany Array.read $ Handle.toChunksWithBufferOf size h
362+-- >>> getBytesWith size h = Stream.unfoldMany Array.read $ Handle.getChunksWith size h
358-- /Pre-release/
364-- /Pre-release/
359−{-# INLINE toBytesWithBufferOf #-}
365+{-# INLINE getBytesWith #-}
360−toBytesWithBufferOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m Word8
366+getBytesWith :: (IsStream t, MonadIO m) => Int -> Handle -> t m Word8
361−toBytesWithBufferOf size h = AS.concat $ toChunksWithBufferOf size h
367+getBytesWith size h = AS.concat $ getChunksWith size h
364-- Generate a stream of elements of the given type from a file 'Handle'.
370-- Generate a stream of elements of the given type from a file 'Handle'.
@@ -377,12 +383,12 @@ read = UF.many A.read readChunks
378-- | Generate a byte stream from a file 'Handle'.
384-- | Generate a byte stream from a file 'Handle'.
380−-- >>> toBytes h = Stream.unfoldMany Array.read $ Handle.toChunks h
386+-- >>> getBytes h = Stream.unfoldMany Array.read $ Handle.getChunks h
382-- /Pre-release/
388-- /Pre-release/
383−{-# INLINE toBytes #-}
389+{-# INLINE getBytes #-}
384−toBytes :: (IsStream t, MonadIO m) => Handle -> t m Word8
390+getBytes :: (IsStream t, MonadIO m) => Handle -> t m Word8
385−toBytes = AS.concat . toChunks
391+getBytes = AS.concat . getChunks
387-------------------------------------------------------------------------------
393-------------------------------------------------------------------------------
388-- Writing
394-- Writing
@@ -427,28 +433,29 @@ putChunks h = S.mapM_ (putChunk h)
427-- AS.concat is written in terms of foldMany. Once that is done we can write
433-- AS.concat is written in terms of foldMany. Once that is done we can write
428-- idiomatic def in the docs.
434-- idiomatic def in the docs.
430−-- | @putChunksWithBufferOf bufsize handle stream@ writes a stream of arrays
436+-- | @putChunksWith bufsize handle stream@ writes a stream of arrays
431-- to @handle@ after coalescing the adjacent arrays in chunks of @bufsize@.
437-- to @handle@ after coalescing the adjacent arrays in chunks of @bufsize@.
432-- The chunk size is only a maximum and the actual writes could be smaller as
438-- The chunk size is only a maximum and the actual writes could be smaller as
433-- we do not split the arrays to fit exactly to the specified size.
439-- we do not split the arrays to fit exactly to the specified size.
435−-- @since 0.7.0
441+-- @since 0.9.0
436−{-# INLINE putChunksWithBufferOf #-}
442+{-# INLINE putChunksWith #-}
437−putChunksWithBufferOf :: (MonadIO m, Storable a)
443+putChunksWith :: (MonadIO m, Storable a)
438 => Int -> Handle -> SerialT m (Array a) -> m ()
444 => Int -> Handle -> SerialT m (Array a) -> m ()
439−putChunksWithBufferOf n h xs = putChunks h $ AS.compact n xs
445+putChunksWith n h xs = putChunks h $ AS.compact n xs
441−-- | @putBytesWithBufferOf bufsize handle stream@ writes @stream@ to @handle@
447+-- | @putBytesWith bufsize handle stream@ writes @stream@ to @handle@
442-- in chunks of @bufsize@. A write is performed to the IO device as soon as we
448-- in chunks of @bufsize@. A write is performed to the IO device as soon as we
443-- collect the required input size.
449-- collect the required input size.
445−-- >>> putBytesWithBufferOf n h m = Handle.putChunks h $ Stream.arraysOf n m
451+-- >>> putBytesWith n h m = Handle.putChunks h $ Stream.arraysOf n m
447−-- @since 0.7.0
453+-- @since 0.9.0
448−{-# INLINE putBytesWithBufferOf #-}
454+{-# INLINE putBytesWith #-}
449−putBytesWithBufferOf :: MonadIO m => Int -> Handle -> SerialT m Word8 -> m ()
455+putBytesWith :: MonadIO m => Int -> Handle -> SerialT m Word8 -> m ()
450−putBytesWithBufferOf n h m = putChunks h $ S.arraysOf n m
456+putBytesWith n h m = putChunks h $ S.arraysOf n m
451−-- putBytesWithBufferOf n h m = putChunks h $ AS.arraysOf n m
458+-- putBytesWith n h m = putChunks h $ AS.arraysOf n m
453-- | Write a byte stream to a file handle. Accumulates the input in chunks of
460-- | Write a byte stream to a file handle. Accumulates the input in chunks of
454-- up to 'Streamly.Internal.Data.Array.Foreign.Type.defaultChunkSize' before writing.
461-- up to 'Streamly.Internal.Data.Array.Foreign.Type.defaultChunkSize' before writing.
@@ -456,12 +463,12 @@ putBytesWithBufferOf n h m = putChunks h $ S.arraysOf n m
456-- NOTE: This may perform better than the 'write' fold, you can try this if you
463-- NOTE: This may perform better than the 'write' fold, you can try this if you
457-- need some extra perf boost.
464-- need some extra perf boost.
459−-- >>> putBytes = Handle.putBytesWithBufferOf IO.defaultChunkSize
466+-- >>> putBytes = Handle.putBytesWith IO.defaultChunkSize
461-- @since 0.7.0
468-- @since 0.7.0
462{-# INLINE putBytes #-}
469{-# INLINE putBytes #-}
463putBytes :: MonadIO m => Handle -> SerialT m Word8 -> m ()
470putBytes :: MonadIO m => Handle -> SerialT m Word8 -> m ()
464−putBytes = putBytesWithBufferOf defaultChunkSize
471+putBytes = putBytesWith defaultChunkSize
466-- | Write a stream of arrays to a handle. Each array in the stream is written
473-- | Write a stream of arrays to a handle. Each array in the stream is written
467-- to the device as a separate IO request.
474-- to the device as a separate IO request.
@@ -482,17 +489,26 @@ consumeChunks = Refold.drainBy putChunk
483-- XXX lpackArraysChunksOf should be written idiomatically
490-- XXX lpackArraysChunksOf should be written idiomatically
485−-- | @writeChunksWithBufferOf bufsize handle@ writes a stream of arrays
492+-- | @writeChunksWith bufsize handle@ writes a stream of arrays
486-- to @handle@ after coalescing the adjacent arrays in chunks of @bufsize@.
493-- to @handle@ after coalescing the adjacent arrays in chunks of @bufsize@.
487-- We never split an array, if a single array is bigger than the specified size
494-- We never split an array, if a single array is bigger than the specified size
488-- it emitted as it is. Multiple arrays are coalesed as long as the total size
495-- it emitted as it is. Multiple arrays are coalesed as long as the total size
489-- remains below the specified size.
496-- remains below the specified size.
499+{-# INLINE writeChunksWith #-}
500+writeChunksWith :: (MonadIO m, Storable a)
501+ => Int -> Handle -> Fold m (Array a) ()
502+writeChunksWith n h = lpackArraysChunksOf n (writeChunks h)
504+-- | Same as 'writeChunksWith'
491-- @since 0.7.0
506-- @since 0.7.0
507+{-# DEPRECATED writeChunksWithBufferOf "Please use writeChunksWith instead." #-}
492{-# INLINE writeChunksWithBufferOf #-}
508{-# INLINE writeChunksWithBufferOf #-}
493writeChunksWithBufferOf :: (MonadIO m, Storable a)
509writeChunksWithBufferOf :: (MonadIO m, Storable a)
494 => Int -> Handle -> Fold m (Array a) ()
510 => Int -> Handle -> Fold m (Array a) ()
495−writeChunksWithBufferOf n h = lpackArraysChunksOf n (writeChunks h)
511+writeChunksWithBufferOf = writeChunksWith
497-- GHC buffer size dEFAULT_FD_BUFFER_SIZE=8192 bytes.
513-- GHC buffer size dEFAULT_FD_BUFFER_SIZE=8192 bytes.
@@ -504,55 +520,63 @@ writeChunksWithBufferOf n h = lpackArraysChunksOf n (writeChunks h)
505-- XXX Maybe we should have a Fold.arraysOf like we have Stream.arraysOf
521-- XXX Maybe we should have a Fold.arraysOf like we have Stream.arraysOf
507−-- | @writeWithBufferOf reqSize handle@ writes the input stream to @handle@.
523+-- | @writeWith reqSize handle@ writes the input stream to @handle@.
508-- Bytes in the input stream are collected into a buffer until we have a chunk
524-- Bytes in the input stream are collected into a buffer until we have a chunk
509-- of @reqSize@ and then written to the IO device.
525-- of @reqSize@ and then written to the IO device.
511−-- >>> writeWithBufferOf n h = Fold.chunksOf n (Array.writeNUnsafe n) (Handle.writeChunks h)
527+-- >>> writeWith n h = Fold.chunksOf n (Array.writeNUnsafe n) (Handle.writeChunks h)
530+{-# INLINE writeWith #-}
531+writeWith :: MonadIO m => Int -> Handle -> Fold m Word8 ()
532+writeWith n h = FL.chunksOf n (writeNUnsafe n) (writeChunks h)
534+-- | Same as 'writeWith'
513-- @since 0.7.0
536-- @since 0.7.0
537+{-# DEPRECATED writeWithBufferOf "Please use writeWith instead." #-}
514{-# INLINE writeWithBufferOf #-}
538{-# INLINE writeWithBufferOf #-}
515writeWithBufferOf :: MonadIO m => Int -> Handle -> Fold m Word8 ()
539writeWithBufferOf :: MonadIO m => Int -> Handle -> Fold m Word8 ()
516−writeWithBufferOf n h = FL.chunksOf n (writeNUnsafe n) (writeChunks h)
540+writeWithBufferOf = writeWith
518-- | Write a stream of 'Maybe' values. Keep buffering the just values in an
542-- | Write a stream of 'Maybe' values. Keep buffering the just values in an
519-- array until a 'Nothing' is encountered or the buffer size exceeds the
543-- array until a 'Nothing' is encountered or the buffer size exceeds the
520-- specified limit, at that point flush the buffer to the handle.
544-- specified limit, at that point flush the buffer to the handle.
522-- /Pre-release/
546-- /Pre-release/
523−{-# INLINE writeMaybesWithBufferOf #-}
547+{-# INLINE writeMaybesWith #-}
524−writeMaybesWithBufferOf :: (MonadIO m )
548+writeMaybesWith :: (MonadIO m )
525 => Int -> Handle -> Fold m (Maybe Word8) ()
549 => Int -> Handle -> Fold m (Maybe Word8) ()
526−writeMaybesWithBufferOf n h =
550+writeMaybesWith n h =
527 let writeNJusts = FL.lmap fromJust $ A.writeN n
551 let writeNJusts = FL.lmap fromJust $ A.writeN n
528 writeOnNothing = FL.takeEndBy_ isNothing writeNJusts
552 writeOnNothing = FL.takeEndBy_ isNothing writeNJusts
529 in FL.many writeOnNothing (writeChunks h)
553 in FL.many writeOnNothing (writeChunks h)
531−-- | Like 'writeWithBufferOf' but uses the experimental 'Refold' API.
555+-- | Like 'writeWith' but uses the experimental 'Refold' API.
533-- /Internal/
557-- /Internal/
534−{-# INLINE consumerWithBufferOf #-}
558+{-# INLINE consumerWith #-}
535−consumerWithBufferOf :: MonadIO m => Int -> Refold m Handle Word8 ()
559+consumerWith :: MonadIO m => Int -> Refold m Handle Word8 ()
536−consumerWithBufferOf n =
560+consumerWith n =
537 FL.refoldMany (FL.take n $ writeNUnsafe n) consumeChunks
561 FL.refoldMany (FL.take n $ writeNUnsafe n) consumeChunks
539-- | Write a byte stream to a file handle. Accumulates the input in chunks of
563-- | Write a byte stream to a file handle. Accumulates the input in chunks of
540-- up to 'Streamly.Internal.Data.Array.Foreign.Type.defaultChunkSize' before writing
564-- up to 'Streamly.Internal.Data.Array.Foreign.Type.defaultChunkSize' before writing
541-- to the IO device.
565-- to the IO device.
543−-- >>> write = Handle.writeWithBufferOf IO.defaultChunkSize
567+-- >>> write = Handle.writeWith IO.defaultChunkSize
545-- @since 0.7.0
569-- @since 0.7.0
546{-# INLINE write #-}
570{-# INLINE write #-}
547write :: MonadIO m => Handle -> Fold m Word8 ()
571write :: MonadIO m => Handle -> Fold m Word8 ()
548−write = writeWithBufferOf defaultChunkSize
572+write = writeWith defaultChunkSize
550-- | Like 'write' but uses the experimental 'Refold' API.
574-- | Like 'write' but uses the experimental 'Refold' API.
552-- /Internal/
576-- /Internal/
553{-# INLINE consumer #-}
577{-# INLINE consumer #-}
554consumer :: MonadIO m => Refold m Handle Word8 ()
578consumer :: MonadIO m => Refold m Handle Word8 ()
555−consumer = consumerWithBufferOf defaultChunkSize
579+consumer = consumerWith defaultChunkSize
558{-# INLINE write #-}
582{-# INLINE write #-}