>> If I'm running register outside runWriterT everything will work.<br><br>Maybe just<br><br>> lift $ register $ print "freed2"<br><br>or I didn't catch something?<br><br><br><br><div class="gmail_quote">
2012/3/1 Alexander V Vershilov <span dir="ltr"><<a href="mailto:alexander.vershilov@gmail.com">alexander.vershilov@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello.<br>
<br>
I'm trying to add monad stack into network-conduit, and everything<br>
works except some details [1].<br>
<br>
I've run runReaderT $ runTCPServer (wrapper around runResourceT) and<br>
inside conduit I want to run writer to gather results of inner computation.<br>
In inner computation I want to use IO, data from outter stack (ReaderT)<br>
so I'm running {-1-}:<br>
<br>
(k,t) <- lift $ runWriterT $ ask >>= \x -> tell [x] {- 1 -}<br>
<br>
and {-2-}<br>
<br>
(k,t) <- lift $ runWriterT $ do {- 2 -}<br>
x <- ask<br>
liftIO $ print $x+1<br>
tell [x]<br>
<br>
and that will work (except I've thought I should not lift runWriterT, but<br>
calling functions inside.<br>
<br>
And finally in computation that will run once I want to register cleaning<br>
function (for example register $ putStrLn "cleaned") ({-3-})<br>
<br>
(k,t) <- lift $ runWriterT $ do {- 3 -}<br>
x <- ask<br>
liftIO $ print $x+1<br>
register $ print "freed2"<br>
tell [x]<br>
<br>
but I've got type error. If I'm running register outside runWriterT everything<br>
will work.<br>
<br>
I would apperated if there will be any suggestions how to make this code<br>
better or use register in internal computation (runWriterT)<br>
<br>
[1] <a href="https://gist.github.com/1941151" target="_blank">https://gist.github.com/1941151</a><br>
--<br>
Best regards,<br>
Alexander V Vershilov<br>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br>