Did you try to use transformers instead of mtl? I am just in doubt about it in my work. <br><br>I've found that Conduit use it. So you remove extra dependency.<br>I hope that transformers have more readable messages (without FD) and you can control what is "lift" more clear.<br>
<br>I have no experience although.<br><br><br><br><div class="gmail_quote">2012/3/2 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">I've found a solution, I should not use lift for runWriterT, and should<br>
explicilty lift all computation of level I need, i.e. (lift.lift) for ask<br>
and lift for register.<br>
<div class="im HOEnZb"><br>
Thu, Mar 01, 2012 at 02:19:29PM +0400, Dmitry Olshansky wrote<br>
</div><div class="HOEnZb"><div class="h5">> >> 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>
> 2012/3/1 Alexander V Vershilov <<a href="mailto:alexander.vershilov@gmail.com">alexander.vershilov@gmail.com</a>><br>
><br>
> 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<br>
> 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>
><br>
><br>
</div></div><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>