on master help sign in
Rename handle based from* APIs to put*
5a7e3efHarendra Kumar
src/Streamly/Internal/Network/Inet/TCP.hs+14−14
@@ -59,13 +59,13 @@ module Streamly.Internal.Network.Inet.TCP
59 -- , writeUtf8ByLines
59 -- , writeUtf8ByLines
60 -- , writeByFrames
60 -- , writeByFrames
61 , writeWithBufferOf
61 , writeWithBufferOf
62− , fromBytes
62+ , putBytes
63− , fromBytesWithBufferOf
63+ , putBytesWithBufferOf
64
64
65 -- -- * Array Write
65 -- -- * Array Write
66 -- , writeArray
66 -- , writeArray
67 , writeChunks
67 , writeChunks
68− , fromChunks
68+ , putChunks
69
69
70 -- ** Transformation
70 -- ** Transformation
71 , processBytes
71 , processBytes
@@ -332,15 +332,15 @@ toBytes addr port = AS.concat $ withConnection addr port ISK.toChunks
332-- number.
332-- number.
333--
333--
334-- @since 0.7.0
334-- @since 0.7.0
335−{-# INLINE fromChunks #-}
335+{-# INLINE putChunks #-}
336−fromChunks
336+putChunks
337 :: (MonadCatch m, MonadAsync m)
337 :: (MonadCatch m, MonadAsync m)
338 => (Word8, Word8, Word8, Word8)
338 => (Word8, Word8, Word8, Word8)
339 -> PortNumber
339 -> PortNumber
340 -> SerialT m (Array Word8)
340 -> SerialT m (Array Word8)
341 -> m ()
341 -> m ()
342−fromChunks addr port xs =
342+putChunks addr port xs =
343− S.drain $ withConnection addr port (\sk -> S.yieldM $ ISK.fromChunks sk xs)
343+ S.drain $ withConnection addr port (\sk -> S.yieldM $ ISK.putChunks sk xs)
344
344
345-- | Write a stream of arrays to the supplied IPv4 host address and port
345-- | Write a stream of arrays to the supplied IPv4 host address and port
346-- number.
346-- number.
@@ -373,15 +373,15 @@ writeChunks addr port = Fold step initial extract
373-- input elements.
373-- input elements.
374--
374--
375-- @since 0.7.0
375-- @since 0.7.0
376−{-# INLINE fromBytesWithBufferOf #-}
376+{-# INLINE putBytesWithBufferOf #-}
377−fromBytesWithBufferOf
377+putBytesWithBufferOf
378 :: (MonadCatch m, MonadAsync m)
378 :: (MonadCatch m, MonadAsync m)
379 => Int
379 => Int
380 -> (Word8, Word8, Word8, Word8)
380 -> (Word8, Word8, Word8, Word8)
381 -> PortNumber
381 -> PortNumber
382 -> SerialT m Word8
382 -> SerialT m Word8
383 -> m ()
383 -> 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
385
385
386-- | Like 'write' but provides control over the write buffer. Output will
386-- | Like 'write' but provides control over the write buffer. Output will
387-- be written to the IO device as soon as we collect the specified number of
387-- be written to the IO device as soon as we collect the specified number of
@@ -401,10 +401,10 @@ writeWithBufferOf n addr port =
401-- | Write a stream to the supplied IPv4 host address and port number.
401-- | Write a stream to the supplied IPv4 host address and port number.
402--
402--
403-- @since 0.7.0
403-- @since 0.7.0
404−{-# INLINE fromBytes #-}
404+{-# INLINE putBytes #-}
405−fromBytes :: (MonadCatch m, MonadAsync m)
405+putBytes :: (MonadCatch m, MonadAsync m)
406 => (Word8, Word8, Word8, Word8) -> PortNumber -> SerialT m Word8 -> m ()
406 => (Word8, Word8, Word8, Word8) -> PortNumber -> SerialT m Word8 -> m ()
407−fromBytes = fromBytesWithBufferOf defaultChunkSize
407+putBytes = putBytesWithBufferOf defaultChunkSize
408
408
409-- | Write a stream to the supplied IPv4 host address and port number.
409-- | Write a stream to the supplied IPv4 host address and port number.
410--
410--
@@ -432,7 +432,7 @@ withInputConnect addr port input f = S.bracket pre post handler
432
432
433 pre = do
433 pre = do
434 sk <- liftIO $ connect addr port
434 sk <- liftIO $ connect addr port
435− tid <- fork (ISK.fromBytes sk input)
435+ tid <- fork (ISK.putBytes sk input)
436 return (sk, tid)
436 return (sk, tid)
437
437
438 handler (sk, _) = f sk
438 handler (sk, _) = f sk
src/Streamly/Internal/Network/Socket.hs+12−12
@@ -48,9 +48,9 @@ module Streamly.Internal.Network.Socket
48 -- , writeByFrames
48 -- , writeByFrames
49 , writeWithBufferOf
49 , writeWithBufferOf
50
50
51− , fromChunks
51+ , putChunks
52− , fromBytesWithBufferOf
52+ , putBytesWithBufferOf
53− , fromBytes
53+ , putBytes
54
54
55 -- -- * Array Write
55 -- -- * Array Write
56 , writeChunk
56 , writeChunk
@@ -444,10 +444,10 @@ read = UF.supplyFirst A.defaultChunkSize readWithBufferOf
444-- | Write a stream of arrays to a handle.
444-- | Write a stream of arrays to a handle.
445--
445--
446-- @since 0.7.0
446-- @since 0.7.0
447−{-# INLINE fromChunks #-}
447+{-# INLINE putChunks #-}
448−fromChunks :: (MonadIO m, Storable a)
448+putChunks :: (MonadIO m, Storable a)
449 => Socket -> SerialT m (Array a) -> m ()
449 => Socket -> SerialT m (Array a) -> m ()
450−fromChunks h = S.mapM_ (liftIO . writeChunk h)
450+putChunks h = S.mapM_ (liftIO . writeChunk h)
451
451
452-- | Write a stream of arrays to a socket. Each array in the stream is written
452-- | Write a stream of arrays to a socket. Each array in the stream is written
453-- to the socket as a separate IO request.
453-- to the socket as a separate IO request.
@@ -482,9 +482,9 @@ writeChunksWithBufferOf n h = lpackArraysChunksOf n (writeChunks h)
482-- input elements.
482-- input elements.
483--
483--
484-- @since 0.7.0
484-- @since 0.7.0
485−{-# INLINE fromBytesWithBufferOf #-}
485+{-# INLINE putBytesWithBufferOf #-}
486−fromBytesWithBufferOf :: MonadIO m => Int -> Socket -> SerialT m Word8 -> m ()
486+putBytesWithBufferOf :: MonadIO m => Int -> Socket -> SerialT m Word8 -> m ()
487−fromBytesWithBufferOf n h m = fromChunks h $ AS.arraysOf n m
487+putBytesWithBufferOf n h m = putChunks h $ AS.arraysOf n m
488
488
489-- | Write a byte stream to a socket. Accumulates the input in chunks of
489-- | Write a byte stream to a socket. Accumulates the input in chunks of
490-- specified number of bytes before writing.
490-- specified number of bytes before writing.
@@ -501,9 +501,9 @@ writeWithBufferOf n h = FL.chunksOf n (A.writeNUnsafe n) (writeChunks h)
501-- depends on the 'IOMode' and the current seek position of the handle.
501-- depends on the 'IOMode' and the current seek position of the handle.
502--
502--
503-- @since 0.7.0
503-- @since 0.7.0
504−{-# INLINE fromBytes #-}
504+{-# INLINE putBytes #-}
505−fromBytes :: MonadIO m => Socket -> SerialT m Word8 -> m ()
505+putBytes :: MonadIO m => Socket -> SerialT m Word8 -> m ()
506−fromBytes = fromBytesWithBufferOf A.defaultChunkSize
506+putBytes = putBytesWithBufferOf A.defaultChunkSize
507
507
508-- | Write a byte stream to a socket. Accumulates the input in chunks of
508-- | Write a byte stream to a socket. Accumulates the input in chunks of
509-- up to 'A.defaultChunkSize' bytes before writing.
509-- up to 'A.defaultChunkSize' bytes before writing.