streamly icon indicating copy to clipboard operation
streamly copied to clipboard

Bracket/bracketIO for Folds

Open mryndzionek opened this issue 5 years ago • 3 comments

I would like to use:

writeChunks :: (MonadIO m, Storable a) => Handle -> Fold m (Array a) ()

but have it more modular, that is, move the handle opening and closing 'inside' the fold. In order to do that I need something like bracketIO, but for Folds. It doesn't seem to be currently available in Streamly. Is there a way to bypass this easily, or do I have to write my own bracketIO?

mryndzionek avatar Apr 07 '20 18:04 mryndzionek

Take a look at this version of writeChunks . It does something similar to what you want.

What the above mentioned writeChunks is doing can be converted into a general Fold bracket combinator I guess.

harendra-kumar avatar Apr 08 '20 10:04 harendra-kumar

Thank you @harendra-kumar.

mryndzionek avatar Apr 08 '20 13:04 mryndzionek

Let's keep this open until it is implemented.

harendra-kumar avatar Apr 10 '20 21:04 harendra-kumar