on master help sign in
rename readRequestsOf to readWithBufferOf etc.
6d0c0e9Harendra Kumar
examples/EchoServer.hs+1−1
@@ -15,5 +15,5 @@ main = S.drain
15 where
15 where
16 echo sk =
16 echo sk =
17 S.fold (writeChunks sk)
17 S.fold (writeChunks sk)
18− $ S.unfold readChunksRequestsOf (32768, sk)
18+ $ S.unfold readChunksWithBufferOf (32768, sk)
19 useWith f sk = finally (liftIO (Net.close sk)) (f sk)
19 useWith f sk = finally (liftIO (Net.close sk)) (f sk)
examples/FileIOExamples.hs+3−3
@@ -10,17 +10,17 @@ import System.Environment (getArgs)
10cat :: FilePath -> IO ()
10cat :: FilePath -> IO ()
11cat src =
11cat src =
12 File.writeChunks "/dev/stdout"
12 File.writeChunks "/dev/stdout"
13− $ File.toChunksRequestsOf (256*1024) src
13+ $ File.toChunksWithBufferOf (256*1024) src
14
14
15cp :: FilePath -> FilePath -> IO ()
15cp :: FilePath -> FilePath -> IO ()
16cp src dst =
16cp src dst =
17 File.writeChunks dst
17 File.writeChunks dst
18− $ File.toChunksRequestsOf (256*1024) src
18+ $ File.toChunksWithBufferOf (256*1024) src
19
19
20append :: FilePath -> FilePath -> IO ()
20append :: FilePath -> FilePath -> IO ()
21append src dst =
21append src dst =
22 File.appendChunks dst
22 File.appendChunks dst
23− $ File.toChunksRequestsOf (256*1024) src
23+ $ File.toChunksWithBufferOf (256*1024) src
24
24
25ord' :: Num a => Char -> a
25ord' :: Num a => Char -> a
26ord' = (fromIntegral . ord)
26ord' = (fromIntegral . ord)
examples/HandleIO.hs+2−2
@@ -15,14 +15,14 @@ import System.IO (IOMode(..), hSeek, SeekMode(..))
15cat :: FH.Handle -> IO ()
15cat :: FH.Handle -> IO ()
16cat src =
16cat src =
17 S.fold (FH.writeChunks FH.stdout)
17 S.fold (FH.writeChunks FH.stdout)
18− $ IFH.toChunksRequestsOf (256*1024) src
18+ $ IFH.toChunksWithBufferOf (256*1024) src
19-- byte stream version
19-- byte stream version
20-- cat src = S.fold (FH.write FH.stdout) $ FH.read src
20-- cat src = S.fold (FH.write FH.stdout) $ FH.read src
21
21
22cp :: FH.Handle -> FH.Handle -> IO ()
22cp :: FH.Handle -> FH.Handle -> IO ()
23cp src dst =
23cp src dst =
24 S.fold (FH.writeChunks dst)
24 S.fold (FH.writeChunks dst)
25− $ IFH.toChunksRequestsOf (256*1024) src
25+ $ IFH.toChunksWithBufferOf (256*1024) src
26-- byte stream version
26-- byte stream version
27-- cp src dst = S.fold (FH.write dst) $ FH.read src
27-- cp src dst = S.fold (FH.write dst) $ FH.read src
28
28
examples/WordCount.hs+1−1
@@ -608,7 +608,7 @@ wc_mwl_parallel src n = do
608 $ S.aheadly
608 $ S.aheadly
609 $ S.maxThreads numCapabilities
609 $ S.maxThreads numCapabilities
610 $ S.mapM (countArray)
610 $ S.mapM (countArray)
611− $ S.unfold FH.readChunksRequestsOf (n, src)
611+ $ S.unfold FH.readChunksWithBufferOf (n, src)
612
612
613-------------------------------------------------------------------------------
613-------------------------------------------------------------------------------
614-- Main
614-- Main
src/Streamly/Benchmark/FileIO/Array.hs+10−10
@@ -124,7 +124,7 @@ inspect $ 'sumBytes `hasNoType` ''Step
124{-# INLINE cat #-}
124{-# INLINE cat #-}
125cat :: Handle -> Handle -> IO ()
125cat :: Handle -> Handle -> IO ()
126cat devNull inh =
126cat devNull inh =
127− S.fold (IFH.writeChunks devNull) $ IFH.toChunksRequestsOf (256*1024) inh
127+ S.fold (IFH.writeChunks devNull) $ IFH.toChunksWithBufferOf (256*1024) inh
128
128
129#ifdef INSPECTION
129#ifdef INSPECTION
130inspect $ hasNoTypeClasses 'cat
130inspect $ hasNoTypeClasses 'cat
@@ -136,7 +136,7 @@ inspect $ 'cat `hasNoType` ''Step
136catBracket :: Handle -> Handle -> IO ()
136catBracket :: Handle -> Handle -> IO ()
137catBracket devNull inh =
137catBracket devNull inh =
138 let readEx = IUF.bracket return (\_ -> hClose inh)
138 let readEx = IUF.bracket return (\_ -> hClose inh)
139− (IUF.supplyFirst FH.readChunksRequestsOf (256*1024))
139+ (IUF.supplyFirst FH.readChunksWithBufferOf (256*1024))
140 in IUF.fold readEx (IFH.writeChunks devNull) inh
140 in IUF.fold readEx (IFH.writeChunks devNull) inh
141
141
142#ifdef INSPECTION
142#ifdef INSPECTION
@@ -149,7 +149,7 @@ inspect $ hasNoTypeClasses 'catBracket
149catBracketStream :: Handle -> Handle -> IO ()
149catBracketStream :: Handle -> Handle -> IO ()
150catBracketStream devNull inh =
150catBracketStream devNull inh =
151 let readEx = S.bracket (return ()) (\_ -> hClose inh)
151 let readEx = S.bracket (return ()) (\_ -> hClose inh)
152− (\_ -> IFH.toChunksRequestsOf (256*1024) inh)
152+ (\_ -> IFH.toChunksWithBufferOf (256*1024) inh)
153 in S.fold (IFH.writeChunks devNull) $ readEx
153 in S.fold (IFH.writeChunks devNull) $ readEx
154
154
155#ifdef INSPECTION
155#ifdef INSPECTION
@@ -162,7 +162,7 @@ inspect $ hasNoTypeClasses 'catBracketStream
162catOnException :: Handle -> Handle -> IO ()
162catOnException :: Handle -> Handle -> IO ()
163catOnException devNull inh =
163catOnException devNull inh =
164 let readEx = IUF.onException (\_ -> hClose inh)
164 let readEx = IUF.onException (\_ -> hClose inh)
165− (IUF.supplyFirst FH.readChunksRequestsOf (256*1024))
165+ (IUF.supplyFirst FH.readChunksWithBufferOf (256*1024))
166 in IUF.fold readEx (IFH.writeChunks devNull) inh
166 in IUF.fold readEx (IFH.writeChunks devNull) inh
167
167
168#ifdef INSPECTION
168#ifdef INSPECTION
@@ -186,10 +186,10 @@ inspect $ 'copy `hasNoType` ''Step
186{-# INLINE linesUnlinesCopy #-}
186{-# INLINE linesUnlinesCopy #-}
187linesUnlinesCopy :: Handle -> Handle -> IO ()
187linesUnlinesCopy :: Handle -> Handle -> IO ()
188linesUnlinesCopy inh outh =
188linesUnlinesCopy inh outh =
189− S.fold (IFH.writeRequestsOf (1024*1024) outh)
189+ S.fold (IFH.writeWithBufferOf (1024*1024) outh)
190 $ AS.interposeSuffix 10
190 $ AS.interposeSuffix 10
191 $ AS.splitOnSuffix 10
191 $ AS.splitOnSuffix 10
192− $ IFH.toChunksRequestsOf (1024*1024) inh
192+ $ IFH.toChunksWithBufferOf (1024*1024) inh
193
193
194#ifdef INSPECTION
194#ifdef INSPECTION
195inspect $ hasNoTypeClassesExcept 'linesUnlinesCopy [''Storable]
195inspect $ hasNoTypeClassesExcept 'linesUnlinesCopy [''Storable]
@@ -200,11 +200,11 @@ inspect $ hasNoTypeClassesExcept 'linesUnlinesCopy [''Storable]
200{-# INLINE wordsUnwordsCopy #-}
200{-# INLINE wordsUnwordsCopy #-}
201wordsUnwordsCopy :: Handle -> Handle -> IO ()
201wordsUnwordsCopy :: Handle -> Handle -> IO ()
202wordsUnwordsCopy inh outh =
202wordsUnwordsCopy inh outh =
203− S.fold (IFH.writeRequestsOf (1024*1024) outh)
203+ S.fold (IFH.writeWithBufferOf (1024*1024) outh)
204 $ AS.interpose 32
204 $ AS.interpose 32
205 -- XXX this is not correct word splitting combinator
205 -- XXX this is not correct word splitting combinator
206 $ AS.splitOn 32
206 $ AS.splitOn 32
207− $ IFH.toChunksRequestsOf (1024*1024) inh
207+ $ IFH.toChunksWithBufferOf (1024*1024) inh
208
208
209#ifdef INSPECTION
209#ifdef INSPECTION
210inspect $ hasNoTypeClassesExcept 'wordsUnwordsCopy [''Storable]
210inspect $ hasNoTypeClassesExcept 'wordsUnwordsCopy [''Storable]
@@ -216,7 +216,7 @@ decodeUtf8Lenient :: Handle -> IO ()
216decodeUtf8Lenient inh =
216decodeUtf8Lenient inh =
217 S.drain
217 S.drain
218 $ IUS.decodeUtf8ArraysLenient
218 $ IUS.decodeUtf8ArraysLenient
219− $ IFH.toChunksRequestsOf (1024*1024) inh
219+ $ IFH.toChunksWithBufferOf (1024*1024) inh
220
220
221#ifdef INSPECTION
221#ifdef INSPECTION
222inspect $ hasNoTypeClasses 'decodeUtf8Lenient
222inspect $ hasNoTypeClasses 'decodeUtf8Lenient
@@ -232,7 +232,7 @@ copyCodecUtf8Lenient inh outh =
232 S.fold (FH.write outh)
232 S.fold (FH.write outh)
233 $ SS.encodeUtf8
233 $ SS.encodeUtf8
234 $ IUS.decodeUtf8ArraysLenient
234 $ IUS.decodeUtf8ArraysLenient
235− $ IFH.toChunksRequestsOf (1024*1024) inh
235+ $ IFH.toChunksWithBufferOf (1024*1024) inh
236
236
237#ifdef INSPECTION
237#ifdef INSPECTION
238inspect $ hasNoTypeClasses 'copyCodecUtf8Lenient
238inspect $ hasNoTypeClasses 'copyCodecUtf8Lenient
src/Streamly/FileSystem/Handle.hs+3−3
@@ -72,9 +72,9 @@ module Streamly.FileSystem.Handle
72 -- encountered.
72 -- encountered.
73
73
74 read
74 read
75− , readRequestsOf
75+ , readWithBufferOf
76 , readChunks
76 , readChunks
77− , readChunksRequestsOf
77+ , readChunksWithBufferOf
78
78
79 -- ** Write to Handle
79 -- ** Write to Handle
80 -- | 'TextEncoding', 'NewLineMode', and 'Buffering' options of the
80 -- | 'TextEncoding', 'NewLineMode', and 'Buffering' options of the
@@ -83,7 +83,7 @@ module Streamly.FileSystem.Handle
83 -- of the handle.
83 -- of the handle.
84
84
85 , write
85 , write
86− , writeRequestsOf
86+ , writeWithBufferOf
87 , writeChunks
87 , writeChunks
88 )
88 )
89where
89where
src/Streamly/Internal/FileSystem/File.hs+22−41
@@ -58,13 +58,13 @@ module Streamly.Internal.FileSystem.File
58 -- , readUtf8
58 -- , readUtf8
59 -- , readLines
59 -- , readLines
60 -- , readFrames
60 -- , readFrames
61− -- , readByChunks
61+ -- , readChunks
62
62
63 -- -- * Array Read
63 -- -- * Array Read
64 -- , readArrayOf
64 -- , readArrayOf
65
65
66− , toChunksRequestsOf
66+ , toChunksWithBufferOf
67− -- , toChunksRequestsOf
67+ -- , toChunksWithBufferOf
68 , toChunks
68 , toChunks
69
69
70 -- ** Write To File
70 -- ** Write To File
@@ -72,7 +72,7 @@ module Streamly.Internal.FileSystem.File
72 -- , writeUtf8
72 -- , writeUtf8
73 -- , writeUtf8ByLines
73 -- , writeUtf8ByLines
74 -- , writeByFrames
74 -- , writeByFrames
75− , writeRequestsOf
75+ , writeWithBufferOf
76
76
77 -- -- * Array Write
77 -- -- * Array Write
78 , writeArray
78 , writeArray
@@ -80,29 +80,10 @@ module Streamly.Internal.FileSystem.File
80
80
81 -- ** Append To File
81 -- ** Append To File
82 , append
82 , append
83− , appendRequestsOf
83+ , appendWithBufferOf
84 -- , appendShared
84 -- , appendShared
85 , appendArray
85 , appendArray
86 , appendChunks
86 , appendChunks
87−
88− -- -- * Random Access (Seek)
89− -- -- | Unlike the streaming APIs listed above, these APIs apply to devices or
90− -- files that have random access or seek capability. This type of devices
91− -- include disks, files, memory devices and exclude terminals, pipes,
92− -- sockets and fifos.
93− --
94− -- , readIndex
95− -- , readSlice
96− -- , readSliceRev
97− -- , readAt -- read from a given position to th end of file
98− -- , readSliceArrayUpto
99− -- , readSliceArrayOf
100−
101− -- , writeIndex
102− -- , writeSlice
103− -- , writeSliceRev
104− -- , writeAt -- start writing at the given position
105− -- , writeSliceArray
106 )
87 )
107where
88where
108
89
@@ -182,14 +163,14 @@ appendArray file arr = SIO.withFile file AppendMode (\h -> FH.writeArray h arr)
182-- Stream of Arrays IO
163-- Stream of Arrays IO
183-------------------------------------------------------------------------------
164-------------------------------------------------------------------------------
184
165
185−-- | @toChunksRequestsOf size file@ reads a stream of arrays from file @file@.
166+-- | @toChunksWithBufferOf size file@ reads a stream of arrays from file @file@.
186-- The maximum size of a single array is specified by @size@. The actual size
167-- The maximum size of a single array is specified by @size@. The actual size
187-- read may be less than or equal to @size@.
168-- read may be less than or equal to @size@.
188−{-# INLINABLE toChunksRequestsOf #-}
169+{-# INLINABLE toChunksWithBufferOf #-}
189−toChunksRequestsOf :: (IsStream t, MonadCatch m, MonadIO m)
170+toChunksWithBufferOf :: (IsStream t, MonadCatch m, MonadIO m)
190 => Int -> FilePath -> t m (Array Word8)
171 => Int -> FilePath -> t m (Array Word8)
191−toChunksRequestsOf size file =
172+toChunksWithBufferOf size file =
192− withFile file ReadMode (FH.toChunksRequestsOf size)
173+ withFile file ReadMode (FH.toChunksWithBufferOf size)
193
174
194-- XXX read 'Array a' instead of Word8
175-- XXX read 'Array a' instead of Word8
195--
176--
@@ -197,13 +178,13 @@ toChunksRequestsOf size file =
197-- The maximum size of a single array is limited to @defaultChunkSize@. The
178-- The maximum size of a single array is limited to @defaultChunkSize@. The
198-- actual size read may be less than @defaultChunkSize@.
179-- actual size read may be less than @defaultChunkSize@.
199--
180--
200−-- > toChunks = toChunksRequestsOf defaultChunkSize
181+-- > toChunks = toChunksWithBufferOf defaultChunkSize
201--
182--
202-- @since 0.7.0
183-- @since 0.7.0
203{-# INLINE toChunks #-}
184{-# INLINE toChunks #-}
204toChunks :: (IsStream t, MonadCatch m, MonadIO m)
185toChunks :: (IsStream t, MonadCatch m, MonadIO m)
205 => FilePath -> t m (Array Word8)
186 => FilePath -> t m (Array Word8)
206−toChunks = toChunksRequestsOf defaultChunkSize
187+toChunks = toChunksWithBufferOf defaultChunkSize
207
188
208-------------------------------------------------------------------------------
189-------------------------------------------------------------------------------
209-- Read File to Stream
190-- Read File to Stream
@@ -220,7 +201,7 @@ toChunks = toChunksRequestsOf defaultChunkSize
220--
201--
221{-# INLINE readInChunksOf #-}
202{-# INLINE readInChunksOf #-}
222readInChunksOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m Word8
203readInChunksOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m Word8
223−readInChunksOf chunkSize h = A.flattenArrays $ toChunksRequestsOf chunkSize h
204+readInChunksOf chunkSize h = A.flattenArrays $ toChunksWithBufferOf chunkSize h
224-}
205-}
225
206
226-- TODO
207-- TODO
@@ -287,12 +268,12 @@ writeChunks = writeChunksMode WriteMode
287-- input elements.
268-- input elements.
288--
269--
289-- @since 0.7.0
270-- @since 0.7.0
290−{-# INLINE writeRequestsOf #-}
271+{-# INLINE writeWithBufferOf #-}
291−writeRequestsOf :: (MonadAsync m, MonadCatch m)
272+writeWithBufferOf :: (MonadAsync m, MonadCatch m)
292 => Int -> FilePath -> SerialT m Word8 -> m ()
273 => Int -> FilePath -> SerialT m Word8 -> m ()
293−writeRequestsOf n file xs = writeChunks file $ AS.arraysOf n xs
274+writeWithBufferOf n file xs = writeChunks file $ AS.arraysOf n xs
294
275
295−-- > write = 'writeRequestsOf' defaultChunkSize
276+-- > write = 'writeWithBufferOf' defaultChunkSize
296--
277--
297-- | Write a byte stream to a file. Combines the bytes in chunks of size
278-- | 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
279-- up to 'A.defaultChunkSize' before writing. If the file exists it is
@@ -302,7 +283,7 @@ writeRequestsOf n file xs = writeChunks file $ AS.arraysOf n xs
302-- @since 0.7.0
283-- @since 0.7.0
303{-# INLINE write #-}
284{-# INLINE write #-}
304write :: (MonadAsync m, MonadCatch m) => FilePath -> SerialT m Word8 -> m ()
285write :: (MonadAsync m, MonadCatch m) => FilePath -> SerialT m Word8 -> m ()
305−write = writeRequestsOf defaultChunkSize
286+write = writeWithBufferOf defaultChunkSize
306
287
307{-
288{-
308{-# INLINE write #-}
289{-# INLINE write #-}
@@ -323,10 +304,10 @@ appendChunks = writeChunksMode AppendMode
323-- input elements.
304-- input elements.
324--
305--
325-- @since 0.7.0
306-- @since 0.7.0
326−{-# INLINE appendRequestsOf #-}
307+{-# INLINE appendWithBufferOf #-}
327−appendRequestsOf :: (MonadAsync m, MonadCatch m)
308+appendWithBufferOf :: (MonadAsync m, MonadCatch m)
328 => Int -> FilePath -> SerialT m Word8 -> m ()
309 => Int -> FilePath -> SerialT m Word8 -> m ()
329−appendRequestsOf n file xs = appendChunks file $ AS.arraysOf n xs
310+appendWithBufferOf n file xs = appendChunks file $ AS.arraysOf n xs
330
311
331-- | Append a byte stream to a file. Combines the bytes in chunks of size up to
312-- | 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
313-- 'A.defaultChunkSize' before writing. If the file exists then the new data
@@ -336,7 +317,7 @@ appendRequestsOf n file xs = appendChunks file $ AS.arraysOf n xs
336-- @since 0.7.0
317-- @since 0.7.0
337{-# INLINE append #-}
318{-# INLINE append #-}
338append :: (MonadAsync m, MonadCatch m) => FilePath -> SerialT m Word8 -> m ()
319append :: (MonadAsync m, MonadCatch m) => FilePath -> SerialT m Word8 -> m ()
339−append = appendRequestsOf defaultChunkSize
320+append = appendWithBufferOf defaultChunkSize
340
321
341{-
322{-
342-- | Like 'append' but the file is not locked for exclusive writes.
323-- | Like 'append' but the file is not locked for exclusive writes.
src/Streamly/Internal/FileSystem/Handle.hs+69−68
@@ -22,18 +22,18 @@ module Streamly.Internal.FileSystem.Handle
22 -- , readUtf8
22 -- , readUtf8
23 -- , readLines
23 -- , readLines
24 -- , readFrames
24 -- , readFrames
25− , readRequestsOf
25+ , readWithBufferOf
26
26
27 , toStream
27 , toStream
28− , toStreamRequestsOf
28+ , toStreamWithBufferOf
29
29
30 -- -- * Array Read
30 -- -- * Array Read
31 -- , readArrayUpto
31 -- , readArrayUpto
32 -- , readArrayOf
32 -- , readArrayOf
33 , readChunks
33 , readChunks
34− , readChunksRequestsOf
34+ , readChunksWithBufferOf
35
35
36− , toChunksRequestsOf
36+ , toChunksWithBufferOf
37 , toChunks
37 , toChunks
38
38
39 -- ** Write to Handle
39 -- ** Write to Handle
@@ -42,20 +42,20 @@ module Streamly.Internal.FileSystem.Handle
42 -- , writeUtf8
42 -- , writeUtf8
43 -- , writeUtf8ByLines
43 -- , writeUtf8ByLines
44 -- , writeByFrames
44 -- , writeByFrames
45− , writeRequestsOf
45+ , writeWithBufferOf
46
46
47 -- Byte stream write (Streams)
47 -- Byte stream write (Streams)
48 , fromStream
48 , fromStream
49− , fromStreamInChunksOf
49+ , fromStreamWithBufferOf
50
50
51 -- -- * Array Write
51 -- -- * Array Write
52 , writeArray
52 , writeArray
53 , writeChunks
53 , writeChunks
54− , writeChunksRequestsOf
54+ , writeChunksWithBufferOf
55
55
56 -- -- * Array stream Write
56 -- -- * Array stream Write
57− , fromStreamArrays
57+ , fromChunks
58− , fromStreamArraysInChunksOf
58+ , fromChunksWithBufferOf
59
59
60 -- -- * Random Access (Seek)
60 -- -- * Random Access (Seek)
61 -- -- | Unlike the streaming APIs listed above, these APIs apply to devices or
61 -- -- | Unlike the streaming APIs listed above, these APIs apply to devices or
@@ -79,8 +79,8 @@ module Streamly.Internal.FileSystem.Handle
79
79
80 -- , readChunksFrom
80 -- , readChunksFrom
81 -- , readChunksFromTo
81 -- , readChunksFromTo
82− -- , readChunksFromToRequestsOf
82+ -- , readChunksFromToWithBufferOf
83− -- , readChunksFromThenToRequestsOf
83+ -- , readChunksFromThenToWithBufferOf
84
84
85 -- , writeIndex
85 -- , writeIndex
86 -- , writeFrom -- start writing at the given position
86 -- , writeFrom -- start writing at the given position
@@ -92,8 +92,8 @@ module Streamly.Internal.FileSystem.Handle
92 --
92 --
93 -- , writeChunksFrom
93 -- , writeChunksFrom
94 -- , writeChunksFromTo
94 -- , writeChunksFromTo
95− -- , writeChunksFromToRequestsOf
95+ -- , writeChunksFromToWithBufferOf
96− -- , writeChunksFromThenToRequestsOf
96+ -- , writeChunksFromThenToWithBufferOf
97 )
97 )
98where
98where
99
99
@@ -164,13 +164,13 @@ readArrayUpto size h = do
164-- Stream of Arrays IO
164-- Stream of Arrays IO
165-------------------------------------------------------------------------------
165-------------------------------------------------------------------------------
166
166
167−-- | @toChunksRequestsOf size h@ reads a stream of arrays from file handle @h@.
167+-- | @toChunksWithBufferOf size h@ reads a stream of arrays from file handle @h@.
168-- The maximum size of a single array is specified by @size@. The actual size
168-- The maximum size of a single array is specified by @size@. The actual size
169-- read may be less than or equal to @size@.
169-- read may be less than or equal to @size@.
170−{-# INLINABLE _toChunksRequestsOf #-}
170+{-# INLINABLE _toChunksWithBufferOf #-}
171−_toChunksRequestsOf :: (IsStream t, MonadIO m)
171+_toChunksWithBufferOf :: (IsStream t, MonadIO m)
172 => Int -> Handle -> t m (Array Word8)
172 => Int -> Handle -> t m (Array Word8)
173−_toChunksRequestsOf size h = go
173+_toChunksWithBufferOf size h = go
174 where
174 where
175 -- XXX use cons/nil instead
175 -- XXX use cons/nil instead
176 go = mkStream $ \_ yld _ stp -> do
176 go = mkStream $ \_ yld _ stp -> do
@@ -179,14 +179,14 @@ _toChunksRequestsOf size h = go
179 then stp
179 then stp
180 else yld arr go
180 else yld arr go
181
181
182−-- | @toChunksRequestsOf size handle@ reads a stream of arrays from the file
182+-- | @toChunksWithBufferOf size handle@ reads a stream of arrays from the file
183-- handle @handle@. The maximum size of a single array is limited to @size@.
183-- handle @handle@. The maximum size of a single array is limited to @size@.
184-- The actual size read may be less than or equal to @size@.
184-- The actual size read may be less than or equal to @size@.
185--
185--
186-- @since 0.7.0
186-- @since 0.7.0
187−{-# INLINE_NORMAL toChunksRequestsOf #-}
187+{-# INLINE_NORMAL toChunksWithBufferOf #-}
188−toChunksRequestsOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m (Array Word8)
188+toChunksWithBufferOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m (Array Word8)
189−toChunksRequestsOf size h = D.fromStreamD (D.Stream step ())
189+toChunksWithBufferOf size h = D.fromStreamD (D.Stream step ())
190 where
190 where
191 {-# INLINE_LATE step #-}
191 {-# INLINE_LATE step #-}
192 step _ _ = do
192 step _ _ = do
@@ -196,14 +196,15 @@ toChunksRequestsOf size h = D.fromStreamD (D.Stream step ())
196 0 -> D.Stop
196 0 -> D.Stop
197 _ -> D.Yield arr ()
197 _ -> D.Yield arr ()
198
198
199−-- | Unfold the tuple @(size, handle)@ into a stream of 'Word8' arrays. The
199+-- | Unfold the tuple @(bufsize, handle)@ into a stream of 'Word8' arrays.
200−-- stream consists of arrays representing chunks of data read from the handle.
200+-- Read requests to the IO device are performed using a buffer of size
201−-- The size of an array in the stream is less than or equal to @size@.
201+-- @bufsize@. The size of an array in the resulting stream is always less than
202+-- or equal to @bufsize@.
202--
203--
203-- @since 0.7.0
204-- @since 0.7.0
204−{-# INLINE_NORMAL readChunksRequestsOf #-}
205+{-# INLINE_NORMAL readChunksWithBufferOf #-}
205−readChunksRequestsOf :: MonadIO m => Unfold m (Int, Handle) (Array Word8)
206+readChunksWithBufferOf :: MonadIO m => Unfold m (Int, Handle) (Array Word8)
206−readChunksRequestsOf = Unfold step return
207+readChunksWithBufferOf = Unfold step return
207 where
208 where
208 {-# INLINE_LATE step #-}
209 {-# INLINE_LATE step #-}
209 step (size, h) = do
210 step (size, h) = do
@@ -220,12 +221,12 @@ readChunksRequestsOf = Unfold step return
220-- @defaultChunkSize@. The actual size read may be less than or equal to
221-- @defaultChunkSize@. The actual size read may be less than or equal to
221-- @defaultChunkSize@.
222-- @defaultChunkSize@.
222--
223--
223−-- > toChunks = toChunksRequestsOf defaultChunkSize
224+-- > toChunks = toChunksWithBufferOf defaultChunkSize
224--
225--
225-- @since 0.7.0
226-- @since 0.7.0
226{-# INLINE toChunks #-}
227{-# INLINE toChunks #-}
227toChunks :: (IsStream t, MonadIO m) => Handle -> t m (Array Word8)
228toChunks :: (IsStream t, MonadIO m) => Handle -> t m (Array Word8)
228−toChunks = toChunksRequestsOf defaultChunkSize
229+toChunks = toChunksWithBufferOf defaultChunkSize
229
230
230-- | Unfolds a handle into a stream of 'Word8' arrays. Requests to the IO
231-- | Unfolds a handle into a stream of 'Word8' arrays. Requests to the IO
231-- device are performed using a buffer of size
232-- device are performed using a buffer of size
@@ -236,7 +237,7 @@ toChunks = toChunksRequestsOf defaultChunkSize
236-- @since 0.7.0
237-- @since 0.7.0
237{-# INLINE readChunks #-}
238{-# INLINE readChunks #-}
238readChunks :: MonadIO m => Unfold m Handle (Array Word8)
239readChunks :: MonadIO m => Unfold m Handle (Array Word8)
239−readChunks = UF.supplyFirst readChunksRequestsOf defaultChunkSize
240+readChunks = UF.supplyFirst readChunksWithBufferOf defaultChunkSize
240
241
241-------------------------------------------------------------------------------
242-------------------------------------------------------------------------------
242-- Read File to Stream
243-- Read File to Stream
@@ -246,21 +247,21 @@ readChunks = UF.supplyFirst readChunksRequestsOf defaultChunkSize
246-- read requests at the same time. For serial case we can use async IO. We can
247-- read requests at the same time. For serial case we can use async IO. We can
247-- also control the read throughput in mbps or IOPS.
248-- also control the read throughput in mbps or IOPS.
248
249
249−-- | Unfolds the tuple @(chunksize, handle)@ into a byte stream, read requests
250+-- | Unfolds the tuple @(bufsize, handle)@ into a byte stream, read requests
250−-- to the IO device are performed using buffers of @chunkSize@.
251+-- to the IO device are performed using buffers of @bufsize@.
251--
252--
252-- @since 0.7.0
253-- @since 0.7.0
253−{-# INLINE readRequestsOf #-}
254+{-# INLINE readWithBufferOf #-}
254−readRequestsOf :: MonadIO m => Unfold m (Int, Handle) Word8
255+readWithBufferOf :: MonadIO m => Unfold m (Int, Handle) Word8
255−readRequestsOf = UF.concat readChunksRequestsOf A.read
256+readWithBufferOf = UF.concat readChunksWithBufferOf A.read
256
257
257−-- | @toStreamRequestsOf chunkSize handle@ reads a byte stream from a file
258+-- | @toStreamWithBufferOf bufsize handle@ reads a byte stream from a file
258−-- handle, reads are performed in chunks of up to @chunkSize@.
259+-- handle, reads are performed in chunks of up to @bufsize@.
259--
260--
260-- /Internal/
261-- /Internal/
261−{-# INLINE toStreamRequestsOf #-}
262+{-# INLINE toStreamWithBufferOf #-}
262−toStreamRequestsOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m Word8
263+toStreamWithBufferOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m Word8
263−toStreamRequestsOf chunkSize h = AS.concat $ toChunksRequestsOf chunkSize h
264+toStreamWithBufferOf chunkSize h = AS.concat $ toChunksWithBufferOf chunkSize h
264
265
265-- TODO
266-- TODO
266-- Generate a stream of elements of the given type from a file 'Handle'.
267-- Generate a stream of elements of the given type from a file 'Handle'.
@@ -273,7 +274,7 @@ toStreamRequestsOf chunkSize h = AS.concat $ toChunksRequestsOf chunkSize h
273-- @since 0.7.0
274-- @since 0.7.0
274{-# INLINE read #-}
275{-# INLINE read #-}
275read :: MonadIO m => Unfold m Handle Word8
276read :: MonadIO m => Unfold m Handle Word8
276−read = UF.supplyFirst readRequestsOf defaultChunkSize
277+read = UF.supplyFirst readWithBufferOf defaultChunkSize
277
278
278-- | Generate a byte stream from a file 'Handle'.
279-- | Generate a byte stream from a file 'Handle'.
279--
280--
@@ -313,33 +314,33 @@ writeArray h Array{..} = withForeignPtr aStart $ \p -> hPutBuf h p aLen
313-- | Write a stream of arrays to a handle.
314-- | Write a stream of arrays to a handle.
314--
315--
315-- @since 0.7.0
316-- @since 0.7.0
316−{-# INLINE fromStreamArrays #-}
317+{-# INLINE fromChunks #-}
317−fromStreamArrays :: (MonadIO m, Storable a)
318+fromChunks :: (MonadIO m, Storable a)
318 => Handle -> SerialT m (Array a) -> m ()
319 => Handle -> SerialT m (Array a) -> m ()
319−fromStreamArrays h m = S.mapM_ (liftIO . writeArray h) m
320+fromChunks h m = S.mapM_ (liftIO . writeArray h) m
320
321
321−-- | @fromStreamArraysInChunksOf chunkSize handle stream@ writes a stream of arrays
322+-- | @fromChunksWithBufferOf bufsize handle stream@ writes a stream of arrays
322−-- to @handle@ after coalescing the adjacent arrays in chunks of @chunkSize@.
323+-- to @handle@ after coalescing the adjacent arrays in chunks of @bufsize@.
323-- The chunk size is only a maximum and the actual writes could be smaller as
324-- The chunk size is only a maximum and the actual writes could be smaller as
324-- we do not split the arrays to fit exactly to the specified size.
325-- we do not split the arrays to fit exactly to the specified size.
325--
326--
326-- @since 0.7.0
327-- @since 0.7.0
327−{-# INLINE fromStreamArraysInChunksOf #-}
328+{-# INLINE fromChunksWithBufferOf #-}
328−fromStreamArraysInChunksOf :: (MonadIO m, Storable a)
329+fromChunksWithBufferOf :: (MonadIO m, Storable a)
329 => Int -> Handle -> SerialT m (Array a) -> m ()
330 => Int -> Handle -> SerialT m (Array a) -> m ()
330−fromStreamArraysInChunksOf n h xs = fromStreamArrays h $ AS.compact n xs
331+fromChunksWithBufferOf n h xs = fromChunks h $ AS.compact n xs
331
332
332−-- | @fromStreamInChunksOf chunkSize handle stream@ writes @stream@ to @handle@ in
333+-- | @fromStreamWithBufferOf bufsize handle stream@ writes @stream@ to @handle@
333−-- chunks of @chunkSize@. A write is performed to the IO device as soon as we
334+-- in chunks of @bufsize@. A write is performed to the IO device as soon as we
334-- collect the required input size.
335-- collect the required input size.
335--
336--
336-- @since 0.7.0
337-- @since 0.7.0
337−{-# INLINE fromStreamInChunksOf #-}
338+{-# INLINE fromStreamWithBufferOf #-}
338−fromStreamInChunksOf :: MonadIO m => Int -> Handle -> SerialT m Word8 -> m ()
339+fromStreamWithBufferOf :: MonadIO m => Int -> Handle -> SerialT m Word8 -> m ()
339−fromStreamInChunksOf n h m = fromStreamArrays h $ S.arraysOf n m
340+fromStreamWithBufferOf n h m = fromChunks h $ S.arraysOf n m
340−-- fromStreamInChunksOf n h m = fromStreamArrays h $ AS.arraysOf n m
341+-- fromStreamWithBufferOf n h m = fromChunks h $ AS.arraysOf n m
341
342
342−-- > write = 'writeRequestsOf' A.defaultChunkSize
343+-- > write = 'writeWithBufferOf' A.defaultChunkSize
343--
344--
344-- | Write a byte stream to a file handle. Accumulates the input in chunks of
345-- | Write a byte stream to a file handle. Accumulates the input in chunks of
345-- up to 'Streamly.Internal.Memory.Array.Types.defaultChunkSize' before writing.
346-- up to 'Streamly.Internal.Memory.Array.Types.defaultChunkSize' before writing.
@@ -350,7 +351,7 @@ fromStreamInChunksOf n h m = fromStreamArrays h $ S.arraysOf n m
350-- @since 0.7.0
351-- @since 0.7.0
351{-# INLINE fromStream #-}
352{-# INLINE fromStream #-}
352fromStream :: MonadIO m => Handle -> SerialT m Word8 -> m ()
353fromStream :: MonadIO m => Handle -> SerialT m Word8 -> m ()
353−fromStream = fromStreamInChunksOf defaultChunkSize
354+fromStream = fromStreamWithBufferOf defaultChunkSize
354
355
355-- | Write a stream of arrays to a handle. Each array in the stream is written
356-- | Write a stream of arrays to a handle. Each array in the stream is written
356-- to the device as a separate IO request.
357-- to the device as a separate IO request.
@@ -360,17 +361,17 @@ fromStream = fromStreamInChunksOf defaultChunkSize
360writeChunks :: (MonadIO m, Storable a) => Handle -> Fold m (Array a) ()
361writeChunks :: (MonadIO m, Storable a) => Handle -> Fold m (Array a) ()
361writeChunks h = FL.drainBy (liftIO . writeArray h)
362writeChunks h = FL.drainBy (liftIO . writeArray h)
362
363
363−-- | @writeChunksRequestsOf chunkSize handle@ writes a stream of arrays
364+-- | @writeChunksWithBufferOf bufsize handle@ writes a stream of arrays
364−-- to @handle@ after coalescing the adjacent arrays in chunks of @chunkSize@.
365+-- to @handle@ after coalescing the adjacent arrays in chunks of @bufsize@.
365-- We never split an array, if a single array is bigger than the specified size
366-- We never split an array, if a single array is bigger than the specified size
366-- it emitted as it is. Multiple arrays are coalesed as long as the total size
367-- it emitted as it is. Multiple arrays are coalesed as long as the total size
367-- remains below the specified size.
368-- remains below the specified size.
368--
369--
369-- @since 0.7.0
370-- @since 0.7.0
370−{-# INLINE writeChunksRequestsOf #-}
371+{-# INLINE writeChunksWithBufferOf #-}
371−writeChunksRequestsOf :: (MonadIO m, Storable a)
372+writeChunksWithBufferOf :: (MonadIO m, Storable a)
372 => Int -> Handle -> Fold m (Array a) ()
373 => Int -> Handle -> Fold m (Array a) ()
373−writeChunksRequestsOf n h = lpackArraysChunksOf n (writeChunks h)
374+writeChunksWithBufferOf n h = lpackArraysChunksOf n (writeChunks h)
374
375
375-- GHC buffer size dEFAULT_FD_BUFFER_SIZE=8192 bytes.
376-- GHC buffer size dEFAULT_FD_BUFFER_SIZE=8192 bytes.
376--
377--
@@ -380,16 +381,16 @@ writeChunksRequestsOf n h = lpackArraysChunksOf n (writeChunks h)
380-- do not want buffering to occur at GHC level as well. Same thing applies to
381-- do not want buffering to occur at GHC level as well. Same thing applies to
381-- writes as well.
382-- writes as well.
382
383
383−-- | @writeRequestsOf reqSize handle@ writes the input stream to @handle@.
384+-- | @writeWithBufferOf reqSize handle@ writes the input stream to @handle@.
384-- Bytes in the input stream are collected into a buffer until we have a chunk
385-- Bytes in the input stream are collected into a buffer until we have a chunk
385-- of @reqSize@ and then written to the IO device.
386-- of @reqSize@ and then written to the IO device.
386--
387--
387-- @since 0.7.0
388-- @since 0.7.0
388−{-# INLINE writeRequestsOf #-}
389+{-# INLINE writeWithBufferOf #-}
389−writeRequestsOf :: MonadIO m => Int -> Handle -> Fold m Word8 ()
390+writeWithBufferOf :: MonadIO m => Int -> Handle -> Fold m Word8 ()
390−writeRequestsOf n h = FL.lchunksOf n (writeNUnsafe n) (writeChunks h)
391+writeWithBufferOf n h = FL.lchunksOf n (writeNUnsafe n) (writeChunks h)
391
392
392−-- > write = 'writeRequestsOf' A.defaultChunkSize
393+-- > write = 'writeWithBufferOf' A.defaultChunkSize
393--
394--
394-- | Write a byte stream to a file handle. Accumulates the input in chunks of
395-- | Write a byte stream to a file handle. Accumulates the input in chunks of
395-- up to 'Streamly.Internal.Memory.Array.Types.defaultChunkSize' before writing
396-- up to 'Streamly.Internal.Memory.Array.Types.defaultChunkSize' before writing
@@ -398,7 +399,7 @@ writeRequestsOf n h = FL.lchunksOf n (writeNUnsafe n) (writeChunks h)
398-- @since 0.7.0
399-- @since 0.7.0
399{-# INLINE write #-}
400{-# INLINE write #-}
400write :: MonadIO m => Handle -> Fold m Word8 ()
401write :: MonadIO m => Handle -> Fold m Word8 ()
401−write = writeRequestsOf defaultChunkSize
402+write = writeWithBufferOf defaultChunkSize
402
403
403{-
404{-
404{-# INLINE write #-}
405{-# INLINE write #-}
src/Streamly/Internal/Network/Socket.hs+38−38
@@ -29,7 +29,7 @@ module Streamly.Internal.Network.Socket
29
29
30 -- * Read from connection
30 -- * Read from connection
31 , read
31 , read
32− , readRequestsOf
32+ , readWithBufferOf
33 -- , readUtf8
33 -- , readUtf8
34 -- , readLines
34 -- , readLines
35 -- , readFrames
35 -- , readFrames
@@ -41,10 +41,10 @@ module Streamly.Internal.Network.Socket
41 -- , readArrayOf
41 -- , readArrayOf
42
42
43 -- , readChunksUpto
43 -- , readChunksUpto
44− , readChunksRequestsOf
44+ , readChunksWithBufferOf
45 , readChunks
45 , readChunks
46
46
47− , toChunksRequestsOf
47+ , toChunksWithBufferOf
48 , toChunks
48 , toChunks
49
49
50 -- * Write to connection
50 -- * Write to connection
@@ -52,7 +52,7 @@ module Streamly.Internal.Network.Socket
52 -- , writeUtf8
52 -- , writeUtf8
53 -- , writeUtf8ByLines
53 -- , writeUtf8ByLines
54 -- , writeByFrames
54 -- , writeByFrames
55− , writeRequestsOf
55+ , writeWithBufferOf
56
56
57 -- -- * Array Write
57 -- -- * Array Write
58 , writeArray
58 , writeArray
@@ -295,14 +295,14 @@ readChunksUptoWith f size h = go
295 then stp
295 then stp
296 else yld arr go
296 else yld arr go
297
297
298−-- | @toChunksRequestsOf size h@ reads a stream of arrays from file handle @h@.
298+-- | @toChunksWithBufferOf size h@ reads a stream of arrays from file handle @h@.
299-- The maximum size of a single array is limited to @size@.
299-- The maximum size of a single array is limited to @size@.
300-- 'fromHandleArraysUpto' ignores the prevailing 'TextEncoding' and 'NewlineMode'
300-- 'fromHandleArraysUpto' ignores the prevailing 'TextEncoding' and 'NewlineMode'
301-- on the 'Handle'.
301-- on the 'Handle'.
302−{-# INLINABLE toChunksRequestsOf #-}
302+{-# INLINABLE toChunksWithBufferOf #-}
303−toChunksRequestsOf :: (IsStream t, MonadIO m)
303+toChunksWithBufferOf :: (IsStream t, MonadIO m)
304 => Int -> Socket -> t m (Array Word8)
304 => Int -> Socket -> t m (Array Word8)
305−toChunksRequestsOf = readChunksUptoWith readArrayOf
305+toChunksWithBufferOf = readChunksUptoWith readArrayOf
306
306
307-- XXX read 'Array a' instead of Word8
307-- XXX read 'Array a' instead of Word8
308--
308--
@@ -312,17 +312,17 @@ toChunksRequestsOf = readChunksUptoWith readArrayOf
312-- @since 0.7.0
312-- @since 0.7.0
313{-# INLINE toChunks #-}
313{-# INLINE toChunks #-}
314toChunks :: (IsStream t, MonadIO m) => Socket -> t m (Array Word8)
314toChunks :: (IsStream t, MonadIO m) => Socket -> t m (Array Word8)
315−toChunks = toChunksRequestsOf A.defaultChunkSize
315+toChunks = toChunksWithBufferOf A.defaultChunkSize
316
316
317−-- | Unfold the tuple @(size, socket)@ into a stream of 'Word8' arrays. The
317+-- | Unfold the tuple @(bufsize, socket)@ into a stream of 'Word8' arrays.
318−-- stream consists of arrays representing chunks of data read from the socket.
318+-- Read requests to the socket are performed using a buffer of size @bufsize@.
319−-- The size of an array in the resulting stream is less than or equal to
319+-- The size of an array in the resulting stream is always less than or equal to
320−-- @size@.
320+-- @bufsize@.
321--
321--
322-- @since 0.7.0
322-- @since 0.7.0
323−{-# INLINE_NORMAL readChunksRequestsOf #-}
323+{-# INLINE_NORMAL readChunksWithBufferOf #-}
324−readChunksRequestsOf :: MonadIO m => Unfold m (Int, Socket) (Array Word8)
324+readChunksWithBufferOf :: MonadIO m => Unfold m (Int, Socket) (Array Word8)
325−readChunksRequestsOf = Unfold step return
325+readChunksWithBufferOf = Unfold step return
326 where
326 where
327 {-# INLINE_LATE step #-}
327 {-# INLINE_LATE step #-}
328 step (size, h) = do
328 step (size, h) = do
@@ -341,7 +341,7 @@ readChunksRequestsOf = Unfold step return
341-- @since 0.7.0
341-- @since 0.7.0
342{-# INLINE readChunks #-}
342{-# INLINE readChunks #-}
343readChunks :: MonadIO m => Unfold m Socket (Array Word8)
343readChunks :: MonadIO m => Unfold m Socket (Array Word8)
344−readChunks = UF.supplyFirst readChunksRequestsOf A.defaultChunkSize
344+readChunks = UF.supplyFirst readChunksWithBufferOf A.defaultChunkSize
345
345
346-------------------------------------------------------------------------------
346-------------------------------------------------------------------------------
347-- Read File to Stream
347-- Read File to Stream
@@ -352,13 +352,13 @@ readChunks = UF.supplyFirst readChunksRequestsOf A.defaultChunkSize
352-- also control the read throughput in mbps or IOPS.
352-- also control the read throughput in mbps or IOPS.
353
353
354{-
354{-
355−-- | @readRequestsOf chunkSize handle@ reads a byte stream from a file
355+-- | @readWithBufferOf bufsize handle@ reads a byte stream from a file
356−-- handle, reads are performed in chunks of up to @chunkSize@. The stream ends
356+-- handle, reads are performed in chunks of up to @bufsize@. The stream ends
357-- as soon as EOF is encountered.
357-- as soon as EOF is encountered.
358--
358--
359−{-# INLINE readRequestsOf #-}
359+{-# INLINE readWithBufferOf #-}
360−readRequestsOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m Word8
360+readWithBufferOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m Word8
361−readRequestsOf chunkSize h = A.flattenArrays $ readChunksUpto chunkSize h
361+readWithBufferOf chunkSize h = A.flattenArrays $ readChunksUpto chunkSize h
362-}
362-}
363
363
364-- TODO
364-- TODO
@@ -373,13 +373,13 @@ readRequestsOf chunkSize h = A.flattenArrays $ readChunksUpto chunkSize h
373toStream :: (IsStream t, MonadIO m) => Socket -> t m Word8
373toStream :: (IsStream t, MonadIO m) => Socket -> t m Word8
374toStream = AS.concat . toChunks
374toStream = AS.concat . toChunks
375
375
376−-- | Unfolds the tuple @(chunksize, socket)@ into a byte stream, read requests
376+-- | Unfolds the tuple @(bufsize, socket)@ into a byte stream, read requests
377−-- to the socket are performed using buffers of @chunkSize@.
377+-- to the socket are performed using buffers of @bufsize@.
378--
378--
379-- @since 0.7.0
379-- @since 0.7.0
380−{-# INLINE readRequestsOf #-}
380+{-# INLINE readWithBufferOf #-}
381−readRequestsOf :: MonadIO m => Unfold m (Int, Socket) Word8
381+readWithBufferOf :: MonadIO m => Unfold m (Int, Socket) Word8
382−readRequestsOf = UF.concat readChunksRequestsOf A.read
382+readWithBufferOf = UF.concat readChunksWithBufferOf A.read
383
383
384-- | Unfolds a 'Socket' into a byte stream. IO requests to the socket are
384-- | Unfolds a 'Socket' into a byte stream. IO requests to the socket are
385-- performed in sizes of
385-- performed in sizes of
@@ -388,7 +388,7 @@ readRequestsOf = UF.concat readChunksRequestsOf A.read
388-- @since 0.7.0
388-- @since 0.7.0
389{-# INLINE read #-}
389{-# INLINE read #-}
390read :: MonadIO m => Unfold m Socket Word8
390read :: MonadIO m => Unfold m Socket Word8
391−read = UF.supplyFirst readRequestsOf A.defaultChunkSize
391+read = UF.supplyFirst readWithBufferOf A.defaultChunkSize
392
392
393-------------------------------------------------------------------------------
393-------------------------------------------------------------------------------
394-- Writing
394-- Writing
@@ -423,19 +423,19 @@ writeChunks h = FL.drainBy (liftIO . writeArray h)
423-- input elements.
423-- input elements.
424--
424--
425-- @since 0.7.0
425-- @since 0.7.0
426−{-# INLINE writeRequestsOfS #-}
426+{-# INLINE writeWithBufferOfS #-}
427−writeRequestsOfS :: MonadIO m => Int -> Socket -> SerialT m Word8 -> m ()
427+writeWithBufferOfS :: MonadIO m => Int -> Socket -> SerialT m Word8 -> m ()
428−writeRequestsOfS n h m = writeChunksS h $ AS.arraysOf n m
428+writeWithBufferOfS n h m = writeChunksS h $ AS.arraysOf n m
429
429
430-- | Write a byte stream to a socket. Accumulates the input in chunks of
430-- | Write a byte stream to a socket. Accumulates the input in chunks of
431-- specified number of bytes before writing.
431-- specified number of bytes before writing.
432--
432--
433-- @since 0.7.0
433-- @since 0.7.0
434−{-# INLINE writeRequestsOf #-}
434+{-# INLINE writeWithBufferOf #-}
435−writeRequestsOf :: MonadIO m => Int -> Socket -> Fold m Word8 ()
435+writeWithBufferOf :: MonadIO m => Int -> Socket -> Fold m Word8 ()
436−writeRequestsOf n h = FL.lchunksOf n (A.writeNUnsafe n) (writeChunks h)
436+writeWithBufferOf n h = FL.lchunksOf n (A.writeNUnsafe n) (writeChunks h)
437
437
438−-- > write = 'writeRequestsOf' A.defaultChunkSize
438+-- > write = 'writeWithBufferOf' A.defaultChunkSize
439--
439--
440-- | Write a byte stream to a file handle. Combines the bytes in chunks of size
440-- | Write a byte stream to a file handle. Combines the bytes in chunks of size
441-- up to 'A.defaultChunkSize' before writing. Note that the write behavior
441-- up to 'A.defaultChunkSize' before writing. Note that the write behavior
@@ -444,19 +444,19 @@ writeRequestsOf n h = FL.lchunksOf n (A.writeNUnsafe n) (writeChunks h)
444-- @since 0.7.0
444-- @since 0.7.0
445{-# INLINE _writeS #-}
445{-# INLINE _writeS #-}
446_writeS :: MonadIO m => Socket -> SerialT m Word8 -> m ()
446_writeS :: MonadIO m => Socket -> SerialT m Word8 -> m ()
447−_writeS = writeRequestsOfS A.defaultChunkSize
447+_writeS = writeWithBufferOfS A.defaultChunkSize
448
448
449-- | Write a byte stream to a socket. Accumulates the input in chunks of
449-- | Write a byte stream to a socket. Accumulates the input in chunks of
450-- up to 'A.defaultChunkSize' bytes before writing.
450-- up to 'A.defaultChunkSize' bytes before writing.
451--
451--
452-- @
452-- @
453−-- write = 'writeRequestsOf' 'A.defaultChunkSize'
453+-- write = 'writeWithBufferOf' 'A.defaultChunkSize'
454-- @
454-- @
455--
455--
456-- @since 0.7.0
456-- @since 0.7.0
457{-# INLINE write #-}
457{-# INLINE write #-}
458write :: MonadIO m => Socket -> Fold m Word8 ()
458write :: MonadIO m => Socket -> Fold m Word8 ()
459−write = writeRequestsOf A.defaultChunkSize
459+write = writeWithBufferOf A.defaultChunkSize
460
460
461{-
461{-
462{-# INLINE write #-}
462{-# INLINE write #-}
src/Streamly/Network/Socket.hs+3−3
@@ -42,13 +42,13 @@ module Streamly.Network.Socket
42
42
43 -- * Read
43 -- * Read
44 , read
44 , read
45− , readRequestsOf
45+ , readWithBufferOf
46 , readChunks
46 , readChunks
47− , readChunksRequestsOf
47+ , readChunksWithBufferOf
48
48
49 -- * Write
49 -- * Write
50 , write
50 , write
51− , writeRequestsOf
51+ , writeWithBufferOf
52 , writeChunks
52 , writeChunks
53 )
53 )
54where
54where