on master help sign in
Rename handle based from* APIs to put*
commit5a7e3efeac64039ab8b42f72eaa9330ad86b05cd authorHarendra Kumar <harendra@composewell.com> dateMon 26 Apr 2021, 00:41 (5 years ago) parenta7ba070
2 files changed+26−26
src/Streamly/Internal/Network/Inet/TCP.hs+14−14 src/Streamly/Internal/Network/Socket.hs+12−12
src/Streamly/Internal/Network/Inet/TCP.hs+14−14
@@ -59,13 +59,13 @@ module Streamly.Internal.Network.Inet.TCP
5959 -- , writeUtf8ByLines
6060 -- , writeByFrames
6161 , writeWithBufferOf
62− , fromBytes
63− , fromBytesWithBufferOf
62+ , putBytes
63+ , putBytesWithBufferOf
6464
6565 -- -- * Array Write
6666 -- , writeArray
6767 , writeChunks
68− , fromChunks
68+ , putChunks
6969
7070 -- ** Transformation
7171 , processBytes
@@ -332,15 +332,15 @@ toBytes addr port = AS.concat $ withConnection addr port ISK.toChunks
332332-- number.
333333--
334334-- @since 0.7.0
335−{-# INLINE fromChunks #-}
336−fromChunks
335+{-# INLINE putChunks #-}
336+putChunks
337337 :: (MonadCatch m, MonadAsync m)
338338 => (Word8, Word8, Word8, Word8)
339339 -> PortNumber
340340 -> SerialT m (Array Word8)
341341 -> m ()
342−fromChunks addr port xs =
343− S.drain $ withConnection addr port (\sk -> S.yieldM $ ISK.fromChunks sk xs)
342+putChunks addr port xs =
343+ S.drain $ withConnection addr port (\sk -> S.yieldM $ ISK.putChunks sk xs)
344344
345345-- | Write a stream of arrays to the supplied IPv4 host address and port
346346-- number.
@@ -373,15 +373,15 @@ writeChunks addr port = Fold step initial extract
373373-- input elements.
374374--
375375-- @since 0.7.0
376−{-# INLINE fromBytesWithBufferOf #-}
377−fromBytesWithBufferOf
376+{-# INLINE putBytesWithBufferOf #-}
377+putBytesWithBufferOf
378378 :: (MonadCatch m, MonadAsync m)
379379 => Int
380380 -> (Word8, Word8, Word8, Word8)
381381 -> PortNumber
382382 -> SerialT m Word8
383383 -> m ()
384−fromBytesWithBufferOf n addr port m = fromChunks addr port $ AS.arraysOf n m
384+putBytesWithBufferOf n addr port m = putChunks addr port $ AS.arraysOf n m
385385
386386-- | Like 'write' but provides control over the write buffer. Output will
387387-- be written to the IO device as soon as we collect the specified number of
@@ -401,10 +401,10 @@ writeWithBufferOf n addr port =
401401-- | Write a stream to the supplied IPv4 host address and port number.
402402--
403403-- @since 0.7.0
404−{-# INLINE fromBytes #-}
405−fromBytes :: (MonadCatch m, MonadAsync m)
404+{-# INLINE putBytes #-}
405+putBytes :: (MonadCatch m, MonadAsync m)
406406 => (Word8, Word8, Word8, Word8) -> PortNumber -> SerialT m Word8 -> m ()
407−fromBytes = fromBytesWithBufferOf defaultChunkSize
407+putBytes = putBytesWithBufferOf defaultChunkSize
408408
409409-- | Write a stream to the supplied IPv4 host address and port number.
410410--
@@ -432,7 +432,7 @@ withInputConnect addr port input f = S.bracket pre post handler
432432
433433 pre = do
434434 sk <- liftIO $ connect addr port
435− tid <- fork (ISK.fromBytes sk input)
435+ tid <- fork (ISK.putBytes sk input)
436436 return (sk, tid)
437437
438438 handler (sk, _) = f sk
src/Streamly/Internal/Network/Socket.hs+12−12
@@ -48,9 +48,9 @@ module Streamly.Internal.Network.Socket
4848 -- , writeByFrames
4949 , writeWithBufferOf
5050
51− , fromChunks
52− , fromBytesWithBufferOf
53− , fromBytes
51+ , putChunks
52+ , putBytesWithBufferOf
53+ , putBytes
5454
5555 -- -- * Array Write
5656 , writeChunk
@@ -444,10 +444,10 @@ read = UF.supplyFirst A.defaultChunkSize readWithBufferOf
444444-- | Write a stream of arrays to a handle.
445445--
446446-- @since 0.7.0
447−{-# INLINE fromChunks #-}
448−fromChunks :: (MonadIO m, Storable a)
447+{-# INLINE putChunks #-}
448+putChunks :: (MonadIO m, Storable a)
449449 => Socket -> SerialT m (Array a) -> m ()
450−fromChunks h = S.mapM_ (liftIO . writeChunk h)
450+putChunks h = S.mapM_ (liftIO . writeChunk h)
451451
452452-- | Write a stream of arrays to a socket. Each array in the stream is written
453453-- to the socket as a separate IO request.
@@ -482,9 +482,9 @@ writeChunksWithBufferOf n h = lpackArraysChunksOf n (writeChunks h)
482482-- input elements.
483483--
484484-- @since 0.7.0
485−{-# INLINE fromBytesWithBufferOf #-}
486−fromBytesWithBufferOf :: MonadIO m => Int -> Socket -> SerialT m Word8 -> m ()
487−fromBytesWithBufferOf n h m = fromChunks h $ AS.arraysOf n m
485+{-# INLINE putBytesWithBufferOf #-}
486+putBytesWithBufferOf :: MonadIO m => Int -> Socket -> SerialT m Word8 -> m ()
487+putBytesWithBufferOf n h m = putChunks h $ AS.arraysOf n m
488488
489489-- | Write a byte stream to a socket. Accumulates the input in chunks of
490490-- specified number of bytes before writing.
@@ -501,9 +501,9 @@ writeWithBufferOf n h = FL.chunksOf n (A.writeNUnsafe n) (writeChunks h)
501501-- depends on the 'IOMode' and the current seek position of the handle.
502502--
503503-- @since 0.7.0
504−{-# INLINE fromBytes #-}
505−fromBytes :: MonadIO m => Socket -> SerialT m Word8 -> m ()
506−fromBytes = fromBytesWithBufferOf A.defaultChunkSize
504+{-# INLINE putBytes #-}
505+putBytes :: MonadIO m => Socket -> SerialT m Word8 -> m ()
506+putBytes = putBytesWithBufferOf A.defaultChunkSize
507507
508508-- | Write a byte stream to a socket. Accumulates the input in chunks of
509509-- up to 'A.defaultChunkSize' bytes before writing.