You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there was a Haskell-pipes mailing list discussion that I started about this a while back. I will link it if I find it later, I searched for a few moments with out luck. I thought this should be documented for others to reference since it is often hard to search through mailing lists.
The conclusion as I remember it was the problem came down to C.bracket in runSafeT.
runSafeT :: (MonadCatch m, MonadIO m) => SafeT m r -> m r
runSafeT m = C.bracket
(liftIO $ newIORef $! Finalizers 0 M.empty)
(\ioref -> do
Finalizers _ fs <- liftIO (readIORef ioref)
mapM snd (M.toDescList fs) )
(R.runReaderT (unSafeT m))
The problem was really about Control.Monad.Catch and last I heard Edward, Gabriel, and Snoyman where going to put their head together and come up with a better Mona.Catch.
I think Gabriel has also mentioned using an idea that is in the ballpark of "free categories" to handle this type of problem among other things.
Here is the example that fails to close the "tmp2" file.
The reason why is that runSafeT uses the MonadCatch interface for the monad beneath it, which does the right thing if the monad beneath it is IO, but does the wrong thing if the monad beneath it is Proxy (because we can't use the MonadCatch interface to call Pipes.Safe.bracket).
I think there was a Haskell-pipes mailing list discussion that I started about this a while back. I will link it if I find it later, I searched for a few moments with out luck. I thought this should be documented for others to reference since it is often hard to search through mailing lists.
The conclusion as I remember it was the problem came down to
C.bracket
inrunSafeT
.The problem was really about Control.Monad.Catch and last I heard Edward, Gabriel, and Snoyman where going to put their head together and come up with a better Mona.Catch.
I think Gabriel has also mentioned using an idea that is in the ballpark of "free categories" to handle this type of problem among other things.
Here is the example that fails to close the "tmp2" file.
I have put the rest of the code in the following gist:
https://gist.github.com/Davorak/f75f6df327cbc4742f16
The text was updated successfully, but these errors were encountered: