michaelt / streaming

An optimized general monad transformer for streaming applications, with a simple prelude of functions
BSD 3-Clause "New" or "Revised" License
104 stars 11 forks source link

writeFile type #17

Open mitchellwrosen opened 8 years ago

mitchellwrosen commented 8 years ago

The documentation of writeFile say that the handle is "crudely" managed by ResourceT. I'm curious, what is crude about this?

Would using monad-control be less crude? i.e.:

writeFile :: MonadBaseControl IO m => FilePath -> Stream (Of String) m r -> m r
writeFile path stream = control (\unlift -> IO.withFile path IO.WriteMode (\handle -> unlift (toHandle handle stream)))

Thanks.

ocharles commented 7 years ago

I believe the crudeness is what I'm talking about in #23 - it won't always release the file handle resource as soon as it can.