#include "inline.hs"
module Streamly.Internal.FileSystem.File
(
withFile
, read
, readChunksWith
, readChunks
, readerWith
, reader
, chunkReaderWith
, chunkReaderFromToWith
, chunkReader
, putChunk
, write
, writeWith
, writeChunks
, fromBytes
, fromBytesWith
, fromChunks
, append
, appendWith
, appendArray
, appendChunks
, readWithBufferOf
, readChunksWithBufferOf
, readChunksFromToWith
, toBytes
, toChunks
, toChunksWithBufferOf
, writeWithBufferOf
, fromBytesWithBufferOf
)
where
import Control.Monad.Catch (MonadCatch)
import Control.Monad.IO.Class (MonadIO(..))
import Data.Word (Word8)
import System.IO (Handle, openFile, IOMode(..), hClose)
import Prelude hiding (read)
import qualified Control.Monad.Catch as MC
import qualified System.IO as SIO
import Streamly.Data.Fold (groupsOf, drain)
import Streamly.Internal.Data.Array.Type (Array(..), writeNUnsafe)
import Streamly.Internal.Data.Fold.Type (Fold(..))
import Streamly.Data.Stream (Stream)
import Streamly.Internal.Data.Unboxed (Unbox)
import Streamly.Internal.Data.Unfold.Type (Unfold(..))
import Streamly.Internal.System.IO (defaultChunkSize)
import qualified Streamly.Data.Array as A
import qualified Streamly.Data.Stream as S
import qualified Streamly.Data.Unfold as UF
import qualified Streamly.Internal.Data.Unfold as UF (bracketIO)
import qualified Streamly.Internal.Data.Fold.Type as FL
(Step(..), snoc, reduce)
import qualified Streamly.Internal.FileSystem.Handle as FH
{-# INLINE withFile #-}
withFile :: (MonadIO m, MonadCatch m)
=> FilePath -> IOMode -> (Handle -> Stream m a) -> Stream m a
withFile :: forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
FilePath -> IOMode -> (Handle -> Stream m a) -> Stream m a
withFile FilePath
file IOMode
mode = forall (m :: * -> *) b c a.
(MonadIO m, MonadCatch m) =>
IO b -> (b -> IO c) -> (b -> Stream m a) -> Stream m a
S.bracketIO (FilePath -> IOMode -> IO Handle
openFile FilePath
file IOMode
mode) Handle -> IO ()
hClose
{-# INLINE usingFile #-}
usingFile :: (MonadIO m, MonadCatch m)
=> Unfold m Handle a -> Unfold m FilePath a
usingFile :: forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
Unfold m Handle a -> Unfold m FilePath a
usingFile = forall (m :: * -> *) a c d b.
(MonadIO m, MonadCatch m) =>
(a -> IO c) -> (c -> IO d) -> Unfold m c b -> Unfold m a b
UF.bracketIO (FilePath -> IOMode -> IO Handle
`openFile` IOMode
ReadMode) Handle -> IO ()
hClose
{-# INLINE usingFile2 #-}
usingFile2 :: (MonadIO m, MonadCatch m)
=> Unfold m (x, Handle) a -> Unfold m (x, FilePath) a
usingFile2 :: forall (m :: * -> *) x a.
(MonadIO m, MonadCatch m) =>
Unfold m (x, Handle) a -> Unfold m (x, FilePath) a
usingFile2 = forall (m :: * -> *) a c d b.
(MonadIO m, MonadCatch m) =>
(a -> IO c) -> (c -> IO d) -> Unfold m c b -> Unfold m a b
UF.bracketIO forall {a}. (a, FilePath) -> IO (a, Handle)
before forall {a}. (a, Handle) -> IO ()
after
where
before :: (a, FilePath) -> IO (a, Handle)
before (a
x, FilePath
file) = do
Handle
h <- FilePath -> IOMode -> IO Handle
openFile FilePath
file IOMode
ReadMode
forall (m :: * -> *) a. Monad m => a -> m a
return (a
x, Handle
h)
after :: (a, Handle) -> IO ()
after (a
_, Handle
h) = Handle -> IO ()
hClose Handle
h
{-# INLINE usingFile3 #-}
usingFile3 :: (MonadIO m, MonadCatch m)
=> Unfold m (x, y, z, Handle) a -> Unfold m (x, y, z, FilePath) a
usingFile3 :: forall (m :: * -> *) x y z a.
(MonadIO m, MonadCatch m) =>
Unfold m (x, y, z, Handle) a -> Unfold m (x, y, z, FilePath) a
usingFile3 = forall (m :: * -> *) a c d b.
(MonadIO m, MonadCatch m) =>
(a -> IO c) -> (c -> IO d) -> Unfold m c b -> Unfold m a b
UF.bracketIO forall {a} {b} {c}. (a, b, c, FilePath) -> IO (a, b, c, Handle)
before forall {a} {b} {c}. (a, b, c, Handle) -> IO ()
after
where
before :: (a, b, c, FilePath) -> IO (a, b, c, Handle)
before (a
x, b
y, c
z, FilePath
file) = do
Handle
h <- FilePath -> IOMode -> IO Handle
openFile FilePath
file IOMode
ReadMode
forall (m :: * -> *) a. Monad m => a -> m a
return (a
x, b
y, c
z, Handle
h)
after :: (a, b, c, Handle) -> IO ()
after (a
_, b
_, c
_, Handle
h) = Handle -> IO ()
hClose Handle
h
{-# INLINABLE putChunk #-}
putChunk :: FilePath -> Array a -> IO ()
putChunk :: forall a. FilePath -> Array a -> IO ()
putChunk FilePath
file Array a
arr = forall r. FilePath -> IOMode -> (Handle -> IO r) -> IO r
SIO.withFile FilePath
file IOMode
WriteMode (forall (m :: * -> *) a. MonadIO m => Handle -> Array a -> m ()
`FH.putChunk` Array a
arr)
{-# INLINABLE appendArray #-}
appendArray :: FilePath -> Array a -> IO ()
appendArray :: forall a. FilePath -> Array a -> IO ()
appendArray FilePath
file Array a
arr = forall r. FilePath -> IOMode -> (Handle -> IO r) -> IO r
SIO.withFile FilePath
file IOMode
AppendMode (forall (m :: * -> *) a. MonadIO m => Handle -> Array a -> m ()
`FH.putChunk` Array a
arr)
{-# INLINE readChunksWith #-}
readChunksWith :: (MonadIO m, MonadCatch m)
=> Int -> FilePath -> Stream m (Array Word8)
readChunksWith :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Int -> FilePath -> Stream m (Array Word8)
readChunksWith Int
size FilePath
file =
forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
FilePath -> IOMode -> (Handle -> Stream m a) -> Stream m a
withFile FilePath
file IOMode
ReadMode (forall (m :: * -> *).
MonadIO m =>
Int -> Handle -> Stream m (Array Word8)
FH.readChunksWith Int
size)
{-# DEPRECATED toChunksWithBufferOf "Please use 'readChunksWith' instead" #-}
{-# INLINE toChunksWithBufferOf #-}
toChunksWithBufferOf :: (MonadIO m, MonadCatch m)
=> Int -> FilePath -> Stream m (Array Word8)
toChunksWithBufferOf :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Int -> FilePath -> Stream m (Array Word8)
toChunksWithBufferOf = forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Int -> FilePath -> Stream m (Array Word8)
readChunksWith
{-# INLINE readChunks #-}
readChunks :: (MonadIO m, MonadCatch m)
=> FilePath -> Stream m (Array Word8)
readChunks :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
FilePath -> Stream m (Array Word8)
readChunks = forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Int -> FilePath -> Stream m (Array Word8)
readChunksWith Int
defaultChunkSize
{-# DEPRECATED toChunks "Please use 'readChunks' instead" #-}
{-# INLINE toChunks #-}
toChunks :: (MonadIO m, MonadCatch m) => FilePath -> Stream m (Array Word8)
toChunks :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
FilePath -> Stream m (Array Word8)
toChunks = forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
FilePath -> Stream m (Array Word8)
readChunks
{-# INLINE chunkReaderWith #-}
chunkReaderWith :: (MonadIO m, MonadCatch m)
=> Unfold m (Int, FilePath) (Array Word8)
chunkReaderWith :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Unfold m (Int, FilePath) (Array Word8)
chunkReaderWith = forall (m :: * -> *) x a.
(MonadIO m, MonadCatch m) =>
Unfold m (x, Handle) a -> Unfold m (x, FilePath) a
usingFile2 forall (m :: * -> *).
MonadIO m =>
Unfold m (Int, Handle) (Array Word8)
FH.chunkReaderWith
{-# DEPRECATED readChunksWithBufferOf
"Please use 'chunkReaderWith' instead" #-}
{-# INLINE readChunksWithBufferOf #-}
readChunksWithBufferOf :: (MonadIO m, MonadCatch m)
=> Unfold m (Int, FilePath) (Array Word8)
readChunksWithBufferOf :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Unfold m (Int, FilePath) (Array Word8)
readChunksWithBufferOf = forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Unfold m (Int, FilePath) (Array Word8)
chunkReaderWith
{-# INLINE chunkReaderFromToWith #-}
chunkReaderFromToWith :: (MonadIO m, MonadCatch m) =>
Unfold m (Int, Int, Int, FilePath) (Array Word8)
chunkReaderFromToWith :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Unfold m (Int, Int, Int, FilePath) (Array Word8)
chunkReaderFromToWith = forall (m :: * -> *) x y z a.
(MonadIO m, MonadCatch m) =>
Unfold m (x, y, z, Handle) a -> Unfold m (x, y, z, FilePath) a
usingFile3 forall (m :: * -> *).
MonadIO m =>
Unfold m (Int, Int, Int, Handle) (Array Word8)
FH.chunkReaderFromToWith
{-# DEPRECATED readChunksFromToWith
"Please use 'chunkReaderFromToWith' instead" #-}
{-# INLINE readChunksFromToWith #-}
readChunksFromToWith :: (MonadIO m, MonadCatch m) =>
Unfold m (Int, Int, Int, FilePath) (Array Word8)
readChunksFromToWith :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Unfold m (Int, Int, Int, FilePath) (Array Word8)
readChunksFromToWith = forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Unfold m (Int, Int, Int, FilePath) (Array Word8)
chunkReaderFromToWith
{-# INLINE chunkReader #-}
chunkReader :: (MonadIO m, MonadCatch m) => Unfold m FilePath (Array Word8)
chunkReader :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Unfold m FilePath (Array Word8)
chunkReader = forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
Unfold m Handle a -> Unfold m FilePath a
usingFile forall (m :: * -> *). MonadIO m => Unfold m Handle (Array Word8)
FH.chunkReader
{-# INLINE readerWith #-}
readerWith :: (MonadIO m, MonadCatch m) => Unfold m (Int, FilePath) Word8
readerWith :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Unfold m (Int, FilePath) Word8
readerWith = forall (m :: * -> *) x a.
(MonadIO m, MonadCatch m) =>
Unfold m (x, Handle) a -> Unfold m (x, FilePath) a
usingFile2 forall (m :: * -> *). MonadIO m => Unfold m (Int, Handle) Word8
FH.readerWith
{-# DEPRECATED readWithBufferOf "Please use 'readerWith' instead" #-}
{-# INLINE readWithBufferOf #-}
readWithBufferOf :: (MonadIO m, MonadCatch m) =>
Unfold m (Int, FilePath) Word8
readWithBufferOf :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Unfold m (Int, FilePath) Word8
readWithBufferOf = forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Unfold m (Int, FilePath) Word8
readerWith
{-# INLINE reader #-}
reader :: (MonadIO m, MonadCatch m) => Unfold m FilePath Word8
reader :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Unfold m FilePath Word8
reader = forall (m :: * -> *) b c a.
Monad m =>
Unfold m b c -> Unfold m a b -> Unfold m a c
UF.many forall (m :: * -> *) a. (Monad m, Unbox a) => Unfold m (Array a) a
A.reader (forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
Unfold m Handle a -> Unfold m FilePath a
usingFile forall (m :: * -> *). MonadIO m => Unfold m Handle (Array Word8)
FH.chunkReader)
{-# INLINE concatChunks #-}
concatChunks :: (Monad m, Unbox a) => Stream m (Array a) -> Stream m a
concatChunks :: forall (m :: * -> *) a.
(Monad m, Unbox a) =>
Stream m (Array a) -> Stream m a
concatChunks = forall (m :: * -> *) a b.
Monad m =>
Unfold m a b -> Stream m a -> Stream m b
S.unfoldMany forall (m :: * -> *) a. (Monad m, Unbox a) => Unfold m (Array a) a
A.reader
{-# INLINE read #-}
read :: (MonadIO m, MonadCatch m) => FilePath -> Stream m Word8
read :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
FilePath -> Stream m Word8
read FilePath
file = forall (m :: * -> *) a.
(Monad m, Unbox a) =>
Stream m (Array a) -> Stream m a
concatChunks forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
FilePath -> IOMode -> (Handle -> Stream m a) -> Stream m a
withFile FilePath
file IOMode
ReadMode forall (m :: * -> *). MonadIO m => Handle -> Stream m (Array Word8)
FH.readChunks
{-# DEPRECATED toBytes "Please use 'read' instead" #-}
{-# INLINE toBytes #-}
toBytes :: (MonadIO m, MonadCatch m) => FilePath -> Stream m Word8
toBytes :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
FilePath -> Stream m Word8
toBytes = forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
FilePath -> Stream m Word8
read
{-# INLINE fromChunksMode #-}
fromChunksMode :: (MonadIO m, MonadCatch m)
=> IOMode -> FilePath -> Stream m (Array a) -> m ()
fromChunksMode :: forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
IOMode -> FilePath -> Stream m (Array a) -> m ()
fromChunksMode IOMode
mode FilePath
file Stream m (Array a)
xs = forall (m :: * -> *) a b.
Monad m =>
Fold m a b -> Stream m a -> m b
S.fold forall (m :: * -> *) a. Monad m => Fold m a ()
drain forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
FilePath -> IOMode -> (Handle -> Stream m a) -> Stream m a
withFile FilePath
file IOMode
mode (\Handle
h -> forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Stream m a -> Stream m b
S.mapM (forall (m :: * -> *) a. MonadIO m => Handle -> Array a -> m ()
FH.putChunk Handle
h) Stream m (Array a)
xs)
{-# INLINE fromChunks #-}
fromChunks :: (MonadIO m, MonadCatch m)
=> FilePath -> Stream m (Array a) -> m ()
fromChunks :: forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
FilePath -> Stream m (Array a) -> m ()
fromChunks = forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
IOMode -> FilePath -> Stream m (Array a) -> m ()
fromChunksMode IOMode
WriteMode
{-# INLINE fromBytesWith #-}
fromBytesWith :: (MonadIO m, MonadCatch m)
=> Int -> FilePath -> Stream m Word8 -> m ()
fromBytesWith :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Int -> FilePath -> Stream m Word8 -> m ()
fromBytesWith Int
n FilePath
file Stream m Word8
xs = forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
FilePath -> Stream m (Array a) -> m ()
fromChunks FilePath
file forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a.
(MonadIO m, Unbox a) =>
Int -> Stream m a -> Stream m (Array a)
S.chunksOf Int
n Stream m Word8
xs
{-# DEPRECATED fromBytesWithBufferOf "Please use 'fromBytesWith' instead" #-}
{-# INLINE fromBytesWithBufferOf #-}
fromBytesWithBufferOf :: (MonadIO m, MonadCatch m)
=> Int -> FilePath -> Stream m Word8 -> m ()
fromBytesWithBufferOf :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Int -> FilePath -> Stream m Word8 -> m ()
fromBytesWithBufferOf = forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Int -> FilePath -> Stream m Word8 -> m ()
fromBytesWith
{-# INLINE fromBytes #-}
fromBytes :: (MonadIO m, MonadCatch m) => FilePath -> Stream m Word8 -> m ()
fromBytes :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
FilePath -> Stream m Word8 -> m ()
fromBytes = forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Int -> FilePath -> Stream m Word8 -> m ()
fromBytesWith Int
defaultChunkSize
{-# INLINE writeChunks #-}
writeChunks :: (MonadIO m, MonadCatch m)
=> FilePath -> Fold m (Array a) ()
writeChunks :: forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
FilePath -> Fold m (Array a) ()
writeChunks FilePath
path = forall (m :: * -> *) a b s.
(s -> a -> m (Step s b))
-> m (Step s b) -> (s -> m b) -> Fold m a b
Fold forall {m :: * -> *} {a} {b} {b}.
(MonadCatch m, MonadIO m) =>
(Fold m a b, Handle) -> a -> m (Step (Fold m a b, Handle) b)
step forall {a} {b}. m (Step (Fold m (Array a) (), Handle) b)
initial forall {m :: * -> *} {a} {b}.
MonadIO m =>
(Fold m a b, Handle) -> m b
extract
where
initial :: m (Step (Fold m (Array a) (), Handle) b)
initial = do
Handle
h <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (FilePath -> IOMode -> IO Handle
openFile FilePath
path IOMode
WriteMode)
Fold m (Array a) ()
fld <- forall (m :: * -> *) a b. Monad m => Fold m a b -> m (Fold m a b)
FL.reduce (forall (m :: * -> *) a. MonadIO m => Handle -> Fold m (Array a) ()
FH.writeChunks Handle
h)
forall (m :: * -> *) a b. MonadCatch m => m a -> m b -> m a
`MC.onException` forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Handle -> IO ()
hClose Handle
h)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall s b. s -> Step s b
FL.Partial (Fold m (Array a) ()
fld, Handle
h)
step :: (Fold m a b, Handle) -> a -> m (Step (Fold m a b, Handle) b)
step (Fold m a b
fld, Handle
h) a
x = do
Fold m a b
r <- forall (m :: * -> *) a b.
Monad m =>
Fold m a b -> a -> m (Fold m a b)
FL.snoc Fold m a b
fld a
x forall (m :: * -> *) a b. MonadCatch m => m a -> m b -> m a
`MC.onException` forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Handle -> IO ()
hClose Handle
h)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall s b. s -> Step s b
FL.Partial (Fold m a b
r, Handle
h)
extract :: (Fold m a b, Handle) -> m b
extract (Fold s -> a -> m (Step s b)
_ m (Step s b)
initial1 s -> m b
extract1, Handle
h) = do
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Handle -> IO ()
hClose Handle
h
Step s b
res <- m (Step s b)
initial1
case Step s b
res of
FL.Partial s
fs -> s -> m b
extract1 s
fs
FL.Done b
fb -> forall (m :: * -> *) a. Monad m => a -> m a
return b
fb
{-# INLINE writeWith #-}
writeWith :: (MonadIO m, MonadCatch m)
=> Int -> FilePath -> Fold m Word8 ()
writeWith :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Int -> FilePath -> Fold m Word8 ()
writeWith Int
n FilePath
path =
forall (m :: * -> *) a b c.
Monad m =>
Int -> Fold m a b -> Fold m b c -> Fold m a c
groupsOf Int
n (forall (m :: * -> *) a.
(MonadIO m, Unbox a) =>
Int -> Fold m a (Array a)
writeNUnsafe Int
n) (forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
FilePath -> Fold m (Array a) ()
writeChunks FilePath
path)
{-# DEPRECATED writeWithBufferOf "Please use 'writeWith' instead" #-}
{-# INLINE writeWithBufferOf #-}
writeWithBufferOf :: (MonadIO m, MonadCatch m)
=> Int -> FilePath -> Fold m Word8 ()
writeWithBufferOf :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Int -> FilePath -> Fold m Word8 ()
writeWithBufferOf = forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Int -> FilePath -> Fold m Word8 ()
writeWith
{-# INLINE write #-}
write :: (MonadIO m, MonadCatch m) => FilePath -> Fold m Word8 ()
write :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
FilePath -> Fold m Word8 ()
write = forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Int -> FilePath -> Fold m Word8 ()
writeWith Int
defaultChunkSize
{-# INLINE appendChunks #-}
appendChunks :: (MonadIO m, MonadCatch m)
=> FilePath -> Stream m (Array a) -> m ()
appendChunks :: forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
FilePath -> Stream m (Array a) -> m ()
appendChunks = forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
IOMode -> FilePath -> Stream m (Array a) -> m ()
fromChunksMode IOMode
AppendMode
{-# INLINE appendWith #-}
appendWith :: (MonadIO m, MonadCatch m)
=> Int -> FilePath -> Stream m Word8 -> m ()
appendWith :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Int -> FilePath -> Stream m Word8 -> m ()
appendWith Int
n FilePath
file Stream m Word8
xs = forall (m :: * -> *) a.
(MonadIO m, MonadCatch m) =>
FilePath -> Stream m (Array a) -> m ()
appendChunks FilePath
file forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a.
(MonadIO m, Unbox a) =>
Int -> Stream m a -> Stream m (Array a)
S.chunksOf Int
n Stream m Word8
xs
{-# INLINE append #-}
append :: (MonadIO m, MonadCatch m) => FilePath -> Stream m Word8 -> m ()
append :: forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
FilePath -> Stream m Word8 -> m ()
append = forall (m :: * -> *).
(MonadIO m, MonadCatch m) =>
Int -> FilePath -> Stream m Word8 -> m ()
appendWith Int
defaultChunkSize