on master help sign in
rename the stream based Handle write APIs
commit8dadcad439a2caadb8489dcbe5ce6987e269d10b authorHarendra Kumar <harendra.kumar@gmail.com> dateMon 30 Sep 2019, 01:59 (7 years ago) parent6225379
2 files changed+23−23
src/Streamly/Benchmark/FileIO/Stream.hs+4−4 src/Streamly/Internal/FileSystem/Handle.hs+19−19
src/Streamly/Benchmark/FileIO/Stream.hs+4−4
@@ -56,7 +56,7 @@ import System.IO (Handle)
5656import Prelude hiding (last, length)
5757
5858import qualified Streamly.FileSystem.Handle as FH
59−import qualified Streamly.Internal.FileSystem.Handle as FH
59+import qualified Streamly.Internal.FileSystem.Handle as IFH
6060import qualified Streamly.Memory.Array as A
6161import qualified Streamly.Internal.Memory.Array.Types as AT
6262import qualified Streamly.Prelude as S
@@ -135,7 +135,7 @@ countLinesU inh =
135135 S.length
136136 $ SS.foldLines FL.drain
137137 $ SS.decodeChar8
138− $ S.concatUnfold A.read (FH.readArrays inh)
138+ $ S.concatUnfold A.read (IFH.readArrays inh)
139139
140140#ifdef INSPECTION
141141inspect $ hasNoTypeClasses 'countLinesU
@@ -170,7 +170,7 @@ inspect $ 'cat `hasNoType` ''D.ConcatMapUState
170170-- | Send the file contents to /dev/null
171171{-# INLINE catStreamWrite #-}
172172catStreamWrite :: Handle -> Handle -> IO ()
173−catStreamWrite devNull inh = FH.writeS devNull $ FH.read inh
173+catStreamWrite devNull inh = IFH.fromStream devNull $ FH.read inh
174174
175175#ifdef INSPECTION
176176inspect $ hasNoTypeClasses 'catStreamWrite
@@ -456,7 +456,7 @@ splitOnSeqUtf8 :: String -> Handle -> IO Int
456456splitOnSeqUtf8 str inh =
457457 (S.length $ IP.splitOnSeq (A.fromList str) FL.drain
458458 $ SS.decodeUtf8ArraysLenient
459− $ FH.readArrays inh) -- >>= print
459+ $ IFH.readArrays inh) -- >>= print
460460
461461-- | Split on suffix sequence.
462462{-# INLINE splitOnSuffixSeq #-}
src/Streamly/Internal/FileSystem/Handle.hs+19−19
@@ -41,8 +41,8 @@ module Streamly.Internal.FileSystem.Handle
4141 , writeInChunksOf
4242
4343 -- Byte stream write (Streams)
44− , writeS
45− , writeSInChunksOf
44+ , fromStream
45+ , fromStreamInChunksOf
4646
4747 -- -- * Array Write
4848 , writeArray
@@ -50,8 +50,8 @@ module Streamly.Internal.FileSystem.Handle
5050 , writeArraysInChunksOf
5151
5252 -- -- * Array stream Write
53− , writeSArrays
54− , writeSArraysInChunksOf
53+ , fromStreamArrays
54+ , fromStreamArraysInChunksOf
5555
5656 -- -- * Random Access (Seek)
5757 -- -- | Unlike the streaming APIs listed above, these APIs apply to devices or
@@ -244,31 +244,31 @@ writeArray h Array{..} = withForeignPtr aStart $ \p -> hPutBuf h p aLen
244244-- | Write a stream of arrays to a handle.
245245--
246246-- @since 0.7.0
247−{-# INLINE writeSArrays #-}
248−writeSArrays :: (MonadIO m, Storable a)
247+{-# INLINE fromStreamArrays #-}
248+fromStreamArrays :: (MonadIO m, Storable a)
249249 => Handle -> SerialT m (Array a) -> m ()
250−writeSArrays h m = S.mapM_ (liftIO . writeArray h) m
250+fromStreamArrays h m = S.mapM_ (liftIO . writeArray h) m
251251
252−-- | @writeArraysPackedUpto chunkSize handle stream@ writes a stream of arrays
252+-- | @fromStreamArraysInChunksOf chunkSize handle stream@ writes a stream of arrays
253253-- to @handle@ after coalescing the adjacent arrays in chunks of @chunkSize@.
254254-- The chunk size is only a maximum and the actual writes could be smaller as
255255-- we do not split the arrays to fit exactly to the specified size.
256256--
257257-- @since 0.7.0
258−{-# INLINE writeSArraysInChunksOf #-}
259−writeSArraysInChunksOf :: (MonadIO m, Storable a)
258+{-# INLINE fromStreamArraysInChunksOf #-}
259+fromStreamArraysInChunksOf :: (MonadIO m, Storable a)
260260 => Int -> Handle -> SerialT m (Array a) -> m ()
261−writeSArraysInChunksOf n h xs = writeSArrays h $ AS.compact n xs
261+fromStreamArraysInChunksOf n h xs = fromStreamArrays h $ AS.compact n xs
262262
263−-- | @writeSInChunksOf chunkSize handle stream@ writes @stream@ to @handle@ in
263+-- | @fromStreamInChunksOf chunkSize handle stream@ writes @stream@ to @handle@ in
264264-- chunks of @chunkSize@. A write is performed to the IO device as soon as we
265265-- collect the required input size.
266266--
267267-- @since 0.7.0
268−{-# INLINE writeSInChunksOf #-}
269−writeSInChunksOf :: MonadIO m => Int -> Handle -> SerialT m Word8 -> m ()
270−writeSInChunksOf n h m = writeSArrays h $ S.arraysOf n m
271−-- writeSInChunksOf n h m = writeSArrays h $ AS.arraysOf n m
268+{-# INLINE fromStreamInChunksOf #-}
269+fromStreamInChunksOf :: MonadIO m => Int -> Handle -> SerialT m Word8 -> m ()
270+fromStreamInChunksOf n h m = fromStreamArrays h $ S.arraysOf n m
271+-- fromStreamInChunksOf n h m = fromStreamArrays h $ AS.arraysOf n m
272272
273273-- > write = 'writeInChunksOf' A.defaultChunkSize
274274--
@@ -279,9 +279,9 @@ writeSInChunksOf n h m = writeSArrays h $ S.arraysOf n m
279279-- need some extra perf boost.
280280--
281281-- @since 0.7.0
282−{-# INLINE writeS #-}
283−writeS :: MonadIO m => Handle -> SerialT m Word8 -> m ()
284−writeS = writeSInChunksOf defaultChunkSize
282+{-# INLINE fromStream #-}
283+fromStream :: MonadIO m => Handle -> SerialT m Word8 -> m ()
284+fromStream = fromStreamInChunksOf defaultChunkSize
285285
286286-- | Write a stream of arrays to a handle.
287287--