on master help sign in
Rename readChunk/writeChunk to getChunk/putChunk
commit2ea9fb04e64bf8eb45996f0b0c27a810f8ed69ae authorHarendra Kumar <harendra@composewell.com> dateThu 20 Oct 2022, 05:16 (4 years ago) parent3db9238
2 files changed+29−16
src/Streamly/Internal/Network/Socket.hs+14−14 src/Streamly/Network/Socket.hs+15−2
src/Streamly/Internal/Network/Socket.hs+14−14
@@ -25,7 +25,7 @@ module Streamly.Internal.Network.Socket
2525 , connectFrom
2626
2727 -- * Read from connection
28− , readChunk
28+ , getChunk
2929
3030 -- ** Streams
3131 , read
@@ -40,7 +40,7 @@ module Streamly.Internal.Network.Socket
4040 , chunkReaderWith
4141
4242 -- * Write to connection
43− , writeChunk
43+ , putChunk
4444
4545 -- ** Folds
4646 , write
@@ -278,10 +278,10 @@ readArrayUptoWith f size h = do
278278-- becomes available. If data is available then it immediately returns that
279279-- data without blocking.
280280--
281−-- @since 0.8.0
282−{-# INLINABLE readChunk #-}
283−readChunk :: Int -> Socket -> IO (Array Word8)
284−readChunk = readArrayUptoWith recvBuf
281+-- @since 0.9.0
282+{-# INLINABLE getChunk #-}
283+getChunk :: Int -> Socket -> IO (Array Word8)
284+getChunk = readArrayUptoWith recvBuf
285285
286286-------------------------------------------------------------------------------
287287-- Array IO (output)
@@ -321,10 +321,10 @@ writeArrayWith f h arr = A.asPtrUnsafe arr $ \ptr -> f h (castPtr ptr) aLen
321321
322322-- | Write an Array to a file handle.
323323--
324−-- @since 0.8.0
325−{-# INLINABLE writeChunk #-}
326−writeChunk :: Unboxed a => Socket -> Array a -> IO ()
327−writeChunk = writeArrayWith sendAll
324+-- @since 0.9.0
325+{-# INLINABLE putChunk #-}
326+putChunk :: Unboxed a => Socket -> Array a -> IO ()
327+putChunk = writeArrayWith sendAll
328328
329329-------------------------------------------------------------------------------
330330-- Stream of Arrays IO
@@ -354,7 +354,7 @@ readChunksWith size h = S.fromStreamD (D.Stream step ())
354354 where
355355 {-# INLINE_LATE step #-}
356356 step _ _ = do
357− arr <- liftIO $ readChunk size h
357+ arr <- liftIO $ getChunk size h
358358 return $
359359 case A.length arr of
360360 0 -> D.Stop
@@ -382,7 +382,7 @@ chunkReaderWith = Unfold step return
382382 where
383383 {-# INLINE_LATE step #-}
384384 step (size, h) = do
385− arr <- liftIO $ readChunk size h
385+ arr <- liftIO $ getChunk size h
386386 return $
387387 case A.length arr of
388388 0 -> D.Stop
@@ -462,7 +462,7 @@ reader = UF.first defaultChunkSize readerWith
462462{-# INLINE putChunks #-}
463463putChunks :: (MonadIO m, Unboxed a)
464464 => Socket -> Stream m (Array a) -> m ()
465−putChunks h = S.fold (FL.drainBy (liftIO . writeChunk h))
465+putChunks h = S.fold (FL.drainBy (liftIO . putChunk h))
466466
467467-- | Write a stream of arrays to a socket. Each array in the stream is written
468468-- to the socket as a separate IO request.
@@ -470,7 +470,7 @@ putChunks h = S.fold (FL.drainBy (liftIO . writeChunk h))
470470-- @since 0.7.0
471471{-# INLINE writeChunks #-}
472472writeChunks :: (MonadIO m, Unboxed a) => Socket -> Fold m (Array a) ()
473−writeChunks h = FL.drainBy (liftIO . writeChunk h)
473+writeChunks h = FL.drainBy (liftIO . putChunk h)
474474
475475-- | @writeChunksWith bufsize socket@ writes a stream of arrays to
476476-- @socket@ after coalescing the adjacent arrays in chunks of @bufsize@.
src/Streamly/Network/Socket.hs+15−2
@@ -101,7 +101,7 @@ module Streamly.Network.Socket
101101
102102 -- * Reads
103103 -- ** Singleton
104− , readChunk
104+ , getChunk
105105
106106 -- ** Unfolds
107107 , reader
@@ -111,7 +111,7 @@ module Streamly.Network.Socket
111111
112112 -- * Writes
113113 -- ** Singleton
114− , writeChunk
114+ , putChunk
115115
116116 -- ** Folds
117117 , write
@@ -124,6 +124,8 @@ module Streamly.Network.Socket
124124
125125 -- * Deprecated
126126 , accept
127+ , readChunk
128+ , writeChunk
127129 , read
128130 , readWithBufferOf
129131 , readChunks
@@ -138,6 +140,7 @@ import Data.Word (Word8)
138140import Network.Socket (Socket, SockAddr)
139141import Streamly.Internal.Data.Unfold.Type (Unfold(..))
140142import Streamly.Internal.Data.Array.Unboxed.Type (Array(..))
143+import Streamly.Internal.Data.Unboxed (Unbox)
141144
142145import Streamly.Internal.Network.Socket hiding (accept, read, readChunks)
143146import Prelude hiding (read)
@@ -147,6 +150,16 @@ import Prelude hiding (read)
147150accept :: MonadIO m => Unfold m (Int, SockSpec, SockAddr) Socket
148151accept = acceptor
149152
153+{-# DEPRECATED readChunk "Please use 'getChunk' instead" #-}
154+{-# INLINABLE readChunk #-}
155+readChunk :: Int -> Socket -> IO (Array Word8)
156+readChunk = getChunk
157+
158+{-# DEPRECATED writeChunk "Please use 'putChunk' instead" #-}
159+{-# INLINABLE writeChunk #-}
160+writeChunk :: Unbox a => Socket -> Array a -> IO ()
161+writeChunk = putChunk
162+
150163{-# DEPRECATED read "Please use 'reader' instead" #-}
151164{-# INLINE read #-}
152165read :: MonadIO m => Unfold m Socket Word8