on master help sign in
rename the stream based Handle write APIs
8dadcadHarendra Kumar
src/Streamly/Benchmark/FileIO/Stream.hs+4−4
@@ -56,7 +56,7 @@ import System.IO (Handle)
56import Prelude hiding (last, length)
56import Prelude hiding (last, length)
57
57
58import qualified Streamly.FileSystem.Handle as FH
58import qualified Streamly.FileSystem.Handle as FH
59−import qualified Streamly.Internal.FileSystem.Handle as FH
59+import qualified Streamly.Internal.FileSystem.Handle as IFH
60import qualified Streamly.Memory.Array as A
60import qualified Streamly.Memory.Array as A
61import qualified Streamly.Internal.Memory.Array.Types as AT
61import qualified Streamly.Internal.Memory.Array.Types as AT
62import qualified Streamly.Prelude as S
62import qualified Streamly.Prelude as S
@@ -135,7 +135,7 @@ countLinesU inh =
135 S.length
135 S.length
136 $ SS.foldLines FL.drain
136 $ SS.foldLines FL.drain
137 $ SS.decodeChar8
137 $ SS.decodeChar8
138− $ S.concatUnfold A.read (FH.readArrays inh)
138+ $ S.concatUnfold A.read (IFH.readArrays inh)
139
139
140#ifdef INSPECTION
140#ifdef INSPECTION
141inspect $ hasNoTypeClasses 'countLinesU
141inspect $ hasNoTypeClasses 'countLinesU
@@ -170,7 +170,7 @@ inspect $ 'cat `hasNoType` ''D.ConcatMapUState
170-- | Send the file contents to /dev/null
170-- | Send the file contents to /dev/null
171{-# INLINE catStreamWrite #-}
171{-# INLINE catStreamWrite #-}
172catStreamWrite :: Handle -> Handle -> IO ()
172catStreamWrite :: Handle -> Handle -> IO ()
173−catStreamWrite devNull inh = FH.writeS devNull $ FH.read inh
173+catStreamWrite devNull inh = IFH.fromStream devNull $ FH.read inh
174
174
175#ifdef INSPECTION
175#ifdef INSPECTION
176inspect $ hasNoTypeClasses 'catStreamWrite
176inspect $ hasNoTypeClasses 'catStreamWrite
@@ -456,7 +456,7 @@ splitOnSeqUtf8 :: String -> Handle -> IO Int
456splitOnSeqUtf8 str inh =
456splitOnSeqUtf8 str inh =
457 (S.length $ IP.splitOnSeq (A.fromList str) FL.drain
457 (S.length $ IP.splitOnSeq (A.fromList str) FL.drain
458 $ SS.decodeUtf8ArraysLenient
458 $ SS.decodeUtf8ArraysLenient
459− $ FH.readArrays inh) -- >>= print
459+ $ IFH.readArrays inh) -- >>= print
460
460
461-- | Split on suffix sequence.
461-- | Split on suffix sequence.
462{-# INLINE splitOnSuffixSeq #-}
462{-# INLINE splitOnSuffixSeq #-}
src/Streamly/Internal/FileSystem/Handle.hs+19−19
@@ -41,8 +41,8 @@ module Streamly.Internal.FileSystem.Handle
41 , writeInChunksOf
41 , writeInChunksOf
42
42
43 -- Byte stream write (Streams)
43 -- Byte stream write (Streams)
44− , writeS
44+ , fromStream
45− , writeSInChunksOf
45+ , fromStreamInChunksOf
46
46
47 -- -- * Array Write
47 -- -- * Array Write
48 , writeArray
48 , writeArray
@@ -50,8 +50,8 @@ module Streamly.Internal.FileSystem.Handle
50 , writeArraysInChunksOf
50 , writeArraysInChunksOf
51
51
52 -- -- * Array stream Write
52 -- -- * Array stream Write
53− , writeSArrays
53+ , fromStreamArrays
54− , writeSArraysInChunksOf
54+ , fromStreamArraysInChunksOf
55
55
56 -- -- * Random Access (Seek)
56 -- -- * Random Access (Seek)
57 -- -- | Unlike the streaming APIs listed above, these APIs apply to devices or
57 -- -- | 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
244-- | Write a stream of arrays to a handle.
244-- | Write a stream of arrays to a handle.
245--
245--
246-- @since 0.7.0
246-- @since 0.7.0
247−{-# INLINE writeSArrays #-}
247+{-# INLINE fromStreamArrays #-}
248−writeSArrays :: (MonadIO m, Storable a)
248+fromStreamArrays :: (MonadIO m, Storable a)
249 => Handle -> SerialT m (Array a) -> m ()
249 => 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
251
251
252−-- | @writeArraysPackedUpto chunkSize handle stream@ writes a stream of arrays
252+-- | @fromStreamArraysInChunksOf chunkSize handle stream@ writes a stream of arrays
253-- to @handle@ after coalescing the adjacent arrays in chunks of @chunkSize@.
253-- to @handle@ after coalescing the adjacent arrays in chunks of @chunkSize@.
254-- The chunk size is only a maximum and the actual writes could be smaller as
254-- The chunk size is only a maximum and the actual writes could be smaller as
255-- we do not split the arrays to fit exactly to the specified size.
255-- we do not split the arrays to fit exactly to the specified size.
256--
256--
257-- @since 0.7.0
257-- @since 0.7.0
258−{-# INLINE writeSArraysInChunksOf #-}
258+{-# INLINE fromStreamArraysInChunksOf #-}
259−writeSArraysInChunksOf :: (MonadIO m, Storable a)
259+fromStreamArraysInChunksOf :: (MonadIO m, Storable a)
260 => Int -> Handle -> SerialT m (Array a) -> m ()
260 => 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
262
262
263−-- | @writeSInChunksOf chunkSize handle stream@ writes @stream@ to @handle@ in
263+-- | @fromStreamInChunksOf chunkSize handle stream@ writes @stream@ to @handle@ in
264-- chunks of @chunkSize@. A write is performed to the IO device as soon as we
264-- chunks of @chunkSize@. A write is performed to the IO device as soon as we
265-- collect the required input size.
265-- collect the required input size.
266--
266--
267-- @since 0.7.0
267-- @since 0.7.0
268−{-# INLINE writeSInChunksOf #-}
268+{-# INLINE fromStreamInChunksOf #-}
269−writeSInChunksOf :: MonadIO m => Int -> Handle -> SerialT m Word8 -> m ()
269+fromStreamInChunksOf :: MonadIO m => Int -> Handle -> SerialT m Word8 -> m ()
270−writeSInChunksOf n h m = writeSArrays h $ S.arraysOf n m
270+fromStreamInChunksOf n h m = fromStreamArrays h $ S.arraysOf n m
271−-- writeSInChunksOf n h m = writeSArrays h $ AS.arraysOf n m
271+-- fromStreamInChunksOf n h m = fromStreamArrays h $ AS.arraysOf n m
272
272
273-- > write = 'writeInChunksOf' A.defaultChunkSize
273-- > write = 'writeInChunksOf' A.defaultChunkSize
274--
274--
@@ -279,9 +279,9 @@ writeSInChunksOf n h m = writeSArrays h $ S.arraysOf n m
279-- need some extra perf boost.
279-- need some extra perf boost.
280--
280--
281-- @since 0.7.0
281-- @since 0.7.0
282−{-# INLINE writeS #-}
282+{-# INLINE fromStream #-}
283−writeS :: MonadIO m => Handle -> SerialT m Word8 -> m ()
283+fromStream :: MonadIO m => Handle -> SerialT m Word8 -> m ()
284−writeS = writeSInChunksOf defaultChunkSize
284+fromStream = fromStreamInChunksOf defaultChunkSize
285
285
286-- | Write a stream of arrays to a handle.
286-- | Write a stream of arrays to a handle.
287--
287--