
On Wed, Jun 5, 2019 at 1:30 PM Daniel Díaz
I tried to tackle this problem in my "streaming-bracketed" library http://hackage.haskell.org/package/streaming-bracketed, by using a "decorator" that wraps regular streams, as opposed to having a resource-aware base monad.
When lifting take-like functions to the decorator, new deallocation actions are inserted.
Oops, I didn't notice this response, sorry! I did look at streaming-bracketed, but I think it doesn't apply in my case, because the file lifespans are overlapping, not nested. If I understand correctly, that's the case where you need something like resourcet, and brackets won't do. In the end, I just gave 'take' a finalizer argument. Not exactly general purpose but it solved my problem.