<pre><span class="comment">As someone suggested me, I can read the logs from Writer and WriterT as computation goes by, <br>if the monoid for the Writer  is lazy readable.<br>This has been true until I tried to put the IO inside WriterT<br>
<br>&gt; {-# LANGUAGE FlexibleContexts #-}</span><br><span class="keyword">&gt; import</span> <span class="conid">Control</span><span class="varop">.</span><span class="conid">Monad</span><span class="varop">.</span><span class="conid">Writer</span><br>
<br><span class="varid">&gt; k</span> <span class="keyglyph">::</span> <span class="layout">(</span><span class="conid">MonadWriter</span> <span class="keyglyph">[</span><span class="conid">Int</span><span class="keyglyph">]</span> <span class="varid">m</span><span class="layout">)</span> <span class="keyglyph">=&gt;</span> <span class="varid">m</span> <span class="keyglyph">[</span><span class="conid">Int</span><span class="keyglyph">]</span><br>
<span class="varid">&gt; k</span> <span class="keyglyph">=</span> <span class="keyword">let</span> <span class="varid">f</span> <span class="varid">x</span> <span class="keyglyph">=</span> <span class="varid">tell</span> <span class="keyglyph">[</span><span class="varid">x</span><span class="keyglyph">]</span> <span class="varop">&gt;&gt;</span> <span class="varid">f</span> <span class="layout">(</span><span class="varid">x</span> <span class="varop">+</span> <span class="num">1</span><span class="layout">)</span> <span class="keyword">in</span> <span class="varid">f</span> <span class="num">0</span><br>
<br>&gt; <span class="varid">works</span> <span class="keyglyph">::</span> <span class="keyglyph">[</span><span class="conid">Int</span><span class="keyglyph">]</span><br><span class="varid">&gt; works</span> <span class="keyglyph">=</span> <span class="varid">snd</span> <span class="varop">$</span> <span class="varid">runWriter</span> <span class="varid">k</span><br>
<br><span class="varid">&gt; hangs</span> <span class="keyglyph">::</span> <span class="conid">IO</span> <span class="keyglyph">[</span><span class="conid">Int</span><span class="keyglyph">]</span><br><span class="varid">&gt; hangs</span> <span class="keyglyph">=</span> <span class="varid">snd</span> <span class="varop">`liftM`</span> <span class="varid">runWriterT</span> <span class="varid">k</span>  <br>
<br>&gt; <span class="varid">main</span> <span class="keyglyph">=</span> <span class="varid">take</span> <span class="num">20</span> <span class="varop">`liftM`</span> <span class="varid">hangs</span> <span class="varop">&gt;&gt;=</span> <span class="varid">print<br>
<br><br>The main hangs both interpreted and compiled on ghc 6.10.1.<br><br>The issue is not exposing with IO alone as<br><br>main = print &quot;test&quot; &gt;&gt; main <br><br>is a working program.<br><br>Thanks for explanations.<br>
<br>paolino<br><br></span></pre>