on master help sign in
Add deprecated versions of renamed APIs (in File module)
commit9d687814126e678e661c324b6c03c0f5d5e706d5 authorHarendra Kumar <harendra@composewell.com> dateFri 21 Oct 2022, 05:04 (4 years ago) parentc02ffa4
1 file changed+58
src/Streamly/Internal/FileSystem/File.hs+58
src/Streamly/Internal/FileSystem/File.hs+58
@@ -81,6 +81,16 @@ module Streamly.Internal.FileSystem.File
8181 -- , appendShared
8282 , appendArray
8383 , appendChunks
84+
85+ -- * Deprecated
86+ , readWithBufferOf
87+ , readChunksWithBufferOf
88+ , readChunksFromToWith
89+ , toBytes
90+ , toChunks
91+ , toChunksWithBufferOf
92+ , writeWithBufferOf
93+ , fromBytesWithBufferOf
8494 )
8595where
8696
@@ -222,6 +232,12 @@ readChunksWith :: (MonadCatch m, MonadAsync m)
222232readChunksWith size file =
223233 withFile file ReadMode (FH.readChunksWith size)
224234
235+{-# DEPRECATED toChunksWithBufferOf "Please use 'readChunksWith' instead" #-}
236+{-# INLINE toChunksWithBufferOf #-}
237+toChunksWithBufferOf :: (MonadCatch m, MonadAsync m)
238+ => Int -> FilePath -> Stream m (Array Word8)
239+toChunksWithBufferOf = readChunksWith
240+
225241-- XXX read 'Array a' instead of Word8
226242--
227243-- | @readChunks file@ reads a stream of arrays from file @file@.
@@ -236,6 +252,11 @@ readChunks :: (MonadCatch m, MonadAsync m)
236252 => FilePath -> Stream m (Array Word8)
237253readChunks = readChunksWith defaultChunkSize
238254
255+{-# DEPRECATED toChunks "Please use 'readChunks' instead" #-}
256+{-# INLINE toChunks #-}
257+toChunks :: (MonadCatch m, MonadAsync m) => FilePath -> Stream m (Array Word8)
258+toChunks = readChunks
259+
239260-------------------------------------------------------------------------------
240261-- Read File to Stream
241262-------------------------------------------------------------------------------
@@ -256,6 +277,13 @@ chunkReaderWith :: (MonadCatch m, MonadAsync m)
256277 => Unfold m (Int, FilePath) (Array Word8)
257278chunkReaderWith = usingFile2 FH.chunkReaderWith
258279
280+{-# DEPRECATED readChunksWithBufferOf
281+ "Please use 'chunkReaderWith' instead" #-}
282+{-# INLINE readChunksWithBufferOf #-}
283+readChunksWithBufferOf :: (MonadCatch m, MonadAsync m)
284+ => Unfold m (Int, FilePath) (Array Word8)
285+readChunksWithBufferOf = chunkReaderWith
286+
259287-- | Unfold the tuple @(from, to, bufsize, filepath)@ into a stream
260288-- of 'Word8' arrays.
261289-- Read requests to the IO device are performed using a buffer of size
@@ -269,6 +297,13 @@ chunkReaderFromToWith :: (MonadCatch m, MonadAsync m) =>
269297 Unfold m (Int, Int, Int, FilePath) (Array Word8)
270298chunkReaderFromToWith = usingFile3 FH.chunkReaderFromToWith
271299
300+{-# DEPRECATED readChunksFromToWith
301+ "Please use 'chunkReaderFromToWith' instead" #-}
302+{-# INLINE readChunksFromToWith #-}
303+readChunksFromToWith :: (MonadCatch m, MonadAsync m) =>
304+ Unfold m (Int, Int, Int, FilePath) (Array Word8)
305+readChunksFromToWith = chunkReaderFromToWith
306+
272307-- | Unfolds a 'FilePath' into a stream of 'Word8' arrays. Requests to the IO
273308-- device are performed using a buffer of size
274309-- 'Streamly.Internal.Data.Array.Unboxed.Type.defaultChunkSize'. The
@@ -288,6 +323,12 @@ chunkReader = usingFile FH.chunkReader
288323readerWith :: (MonadCatch m, MonadAsync m) => Unfold m (Int, FilePath) Word8
289324readerWith = usingFile2 FH.readerWith
290325
326+{-# DEPRECATED readWithBufferOf "Please use 'readerWith' instead" #-}
327+{-# INLINE readWithBufferOf #-}
328+readWithBufferOf :: (MonadCatch m, MonadAsync m) =>
329+ Unfold m (Int, FilePath) Word8
330+readWithBufferOf = readerWith
331+
291332-- | Unfolds a file path into a byte stream. IO requests to the device are
292333-- performed in sizes of
293334-- 'Streamly.Internal.Data.Array.Unboxed.Type.defaultChunkSize'.
@@ -307,6 +348,11 @@ reader = UF.many A.reader (usingFile FH.chunkReader)
307348read :: (MonadCatch m, MonadAsync m) => FilePath -> Stream m Word8
308349read file = AS.concat $ withFile file ReadMode FH.readChunks
309350
351+{-# DEPRECATED toBytes "Please use 'read' instead" #-}
352+{-# INLINE toBytes #-}
353+toBytes :: (MonadCatch m, MonadAsync m) => FilePath -> Stream m Word8
354+toBytes = read
355+
310356{-
311357-- | Generate a stream of elements of the given type from a file 'Handle'. The
312358-- stream ends when EOF is encountered. File is not locked for exclusive reads,
@@ -354,6 +400,12 @@ fromBytesWith :: (MonadAsync m, MonadCatch m)
354400 => Int -> FilePath -> Stream m Word8 -> m ()
355401fromBytesWith n file xs = fromChunks file $ AS.arraysOf n xs
356402
403+{-# DEPRECATED fromBytesWithBufferOf "Please use 'fromBytesWith' instead" #-}
404+{-# INLINE fromBytesWithBufferOf #-}
405+fromBytesWithBufferOf :: (MonadAsync m, MonadCatch m)
406+ => Int -> FilePath -> Stream m Word8 -> m ()
407+fromBytesWithBufferOf = fromBytesWith
408+
357409-- > write = 'writeWith' defaultChunkSize
358410--
359411-- | Write a byte stream to a file. Combines the bytes in chunks of size
@@ -407,6 +459,12 @@ writeWith :: (MonadIO m, MonadCatch m)
407459writeWith n path =
408460 chunksOf n (writeNUnsafe n) (writeChunks path)
409461
462+{-# DEPRECATED writeWithBufferOf "Please use 'writeWith' instead" #-}
463+{-# INLINE writeWithBufferOf #-}
464+writeWithBufferOf :: (MonadIO m, MonadCatch m)
465+ => Int -> FilePath -> Fold m Word8 ()
466+writeWithBufferOf = writeWith
467+
410468-- > write = 'writeWith' A.defaultChunkSize
411469--
412470-- | Write a byte stream to a file. Accumulates the input in chunks of up to