I must ask why runWriterT k :: State s (a,[Int]) is working. <br>Looks like I could runIO the same way I evalState there.<br>In that case I wouldn&#39;t wait for the State s action to finish.<br><br>Thanks<br><br><br><div class="gmail_quote">
2008/12/31 Derek Elkins <span dir="ltr">&lt;<a href="mailto:derek.a.elkins@gmail.com">derek.a.elkins@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Wed, 2008-12-31 at 21:48 +0100, Paolino wrote:<br>
&gt; As someone suggested me, I can read the logs from Writer and WriterT as computation goes by,<br>
&gt; if the monoid for the Writer &nbsp;is lazy readable.<br>
&gt; This has been true until I tried to put the IO inside WriterT<br>
&gt;<br>
&gt;<br>
&gt; &gt; {-# LANGUAGE FlexibleContexts #-}<br>
&gt; &gt; import Control.Monad.Writer<br>
&gt;<br>
&gt;<br>
&gt; &gt; k :: (MonadWriter [Int] m) =&gt; m [Int]<br>
&gt;<br>
&gt; &gt; k = let f x = tell [x] &gt;&gt; f (x + 1) in f 0<br>
&gt;<br>
&gt;<br>
&gt; &gt; works :: [Int]<br>
&gt; &gt; works = snd $ runWriter k<br>
&gt;<br>
&gt;<br>
&gt; &gt; hangs :: IO [Int]<br>
&gt; &gt; hangs = snd `liftM` runWriterT k<br>
<br>
</div>runWriterT :: MonadWriter w m a =&gt; WriterT w m a -&gt; m (a, w)<br>
<br>
which is to say runWriterT k :: IO (a, [Int])<br>
<br>
It&#39;s not going to return anything until the IO action terminates, which is to say never.<br>
<br>
</blockquote></div><br>