on master help sign in
Add deprecated versions of renamed APIs (in File module)
9d68781Harendra Kumar
src/Streamly/Internal/FileSystem/File.hs+58
@@ -81,6 +81,16 @@ module Streamly.Internal.FileSystem.File
81 -- , appendShared
81 -- , appendShared
82 , appendArray
82 , appendArray
83 , appendChunks
83 , appendChunks
84+
85+ -- * Deprecated
86+ , readWithBufferOf
87+ , readChunksWithBufferOf
88+ , readChunksFromToWith
89+ , toBytes
90+ , toChunks
91+ , toChunksWithBufferOf
92+ , writeWithBufferOf
93+ , fromBytesWithBufferOf
84 )
94 )
85where
95where
86
96
@@ -222,6 +232,12 @@ readChunksWith :: (MonadCatch m, MonadAsync m)
222readChunksWith size file =
232readChunksWith size file =
223 withFile file ReadMode (FH.readChunksWith size)
233 withFile file ReadMode (FH.readChunksWith size)
224
234
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+
225-- XXX read 'Array a' instead of Word8
241-- XXX read 'Array a' instead of Word8
226--
242--
227-- | @readChunks file@ reads a stream of arrays from file @file@.
243-- | @readChunks file@ reads a stream of arrays from file @file@.
@@ -236,6 +252,11 @@ readChunks :: (MonadCatch m, MonadAsync m)
236 => FilePath -> Stream m (Array Word8)
252 => FilePath -> Stream m (Array Word8)
237readChunks = readChunksWith defaultChunkSize
253readChunks = readChunksWith defaultChunkSize
238
254
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+
239-------------------------------------------------------------------------------
260-------------------------------------------------------------------------------
240-- Read File to Stream
261-- Read File to Stream
241-------------------------------------------------------------------------------
262-------------------------------------------------------------------------------
@@ -256,6 +277,13 @@ chunkReaderWith :: (MonadCatch m, MonadAsync m)
256 => Unfold m (Int, FilePath) (Array Word8)
277 => Unfold m (Int, FilePath) (Array Word8)
257chunkReaderWith = usingFile2 FH.chunkReaderWith
278chunkReaderWith = usingFile2 FH.chunkReaderWith
258
279
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+
259-- | Unfold the tuple @(from, to, bufsize, filepath)@ into a stream
287-- | Unfold the tuple @(from, to, bufsize, filepath)@ into a stream
260-- of 'Word8' arrays.
288-- of 'Word8' arrays.
261-- Read requests to the IO device are performed using a buffer of size
289-- Read requests to the IO device are performed using a buffer of size
@@ -269,6 +297,13 @@ chunkReaderFromToWith :: (MonadCatch m, MonadAsync m) =>
269 Unfold m (Int, Int, Int, FilePath) (Array Word8)
297 Unfold m (Int, Int, Int, FilePath) (Array Word8)
270chunkReaderFromToWith = usingFile3 FH.chunkReaderFromToWith
298chunkReaderFromToWith = usingFile3 FH.chunkReaderFromToWith
271
299
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+
272-- | Unfolds a 'FilePath' into a stream of 'Word8' arrays. Requests to the IO
307-- | Unfolds a 'FilePath' into a stream of 'Word8' arrays. Requests to the IO
273-- device are performed using a buffer of size
308-- device are performed using a buffer of size
274-- 'Streamly.Internal.Data.Array.Unboxed.Type.defaultChunkSize'. The
309-- 'Streamly.Internal.Data.Array.Unboxed.Type.defaultChunkSize'. The
@@ -288,6 +323,12 @@ chunkReader = usingFile FH.chunkReader
288readerWith :: (MonadCatch m, MonadAsync m) => Unfold m (Int, FilePath) Word8
323readerWith :: (MonadCatch m, MonadAsync m) => Unfold m (Int, FilePath) Word8
289readerWith = usingFile2 FH.readerWith
324readerWith = usingFile2 FH.readerWith
290
325
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+
291-- | Unfolds a file path into a byte stream. IO requests to the device are
332-- | Unfolds a file path into a byte stream. IO requests to the device are
292-- performed in sizes of
333-- performed in sizes of
293-- 'Streamly.Internal.Data.Array.Unboxed.Type.defaultChunkSize'.
334-- 'Streamly.Internal.Data.Array.Unboxed.Type.defaultChunkSize'.
@@ -307,6 +348,11 @@ reader = UF.many A.reader (usingFile FH.chunkReader)
307read :: (MonadCatch m, MonadAsync m) => FilePath -> Stream m Word8
348read :: (MonadCatch m, MonadAsync m) => FilePath -> Stream m Word8
308read file = AS.concat $ withFile file ReadMode FH.readChunks
349read file = AS.concat $ withFile file ReadMode FH.readChunks
309
350
351+{-# DEPRECATED toBytes "Please use 'read' instead" #-}
352+{-# INLINE toBytes #-}
353+toBytes :: (MonadCatch m, MonadAsync m) => FilePath -> Stream m Word8
354+toBytes = read
355+
310{-
356{-
311-- | Generate a stream of elements of the given type from a file 'Handle'. The
357-- | Generate a stream of elements of the given type from a file 'Handle'. The
312-- stream ends when EOF is encountered. File is not locked for exclusive reads,
358-- stream ends when EOF is encountered. File is not locked for exclusive reads,
@@ -354,6 +400,12 @@ fromBytesWith :: (MonadAsync m, MonadCatch m)
354 => Int -> FilePath -> Stream m Word8 -> m ()
400 => Int -> FilePath -> Stream m Word8 -> m ()
355fromBytesWith n file xs = fromChunks file $ AS.arraysOf n xs
401fromBytesWith n file xs = fromChunks file $ AS.arraysOf n xs
356
402
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+
357-- > write = 'writeWith' defaultChunkSize
409-- > write = 'writeWith' defaultChunkSize
358--
410--
359-- | Write a byte stream to a file. Combines the bytes in chunks of size
411-- | Write a byte stream to a file. Combines the bytes in chunks of size
@@ -407,6 +459,12 @@ writeWith :: (MonadIO m, MonadCatch m)
407writeWith n path =
459writeWith n path =
408 chunksOf n (writeNUnsafe n) (writeChunks path)
460 chunksOf n (writeNUnsafe n) (writeChunks path)
409
461
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+
410-- > write = 'writeWith' A.defaultChunkSize
468-- > write = 'writeWith' A.defaultChunkSize
411--
469--
412-- | Write a byte stream to a file. Accumulates the input in chunks of up to
470-- | Write a byte stream to a file. Accumulates the input in chunks of up to