<div class="gmail_quote"><br>However it does not work as I expected. I īm interested in memory management.<div><br></div><div>I though that</div><div><br></div><div>ghci&gt; let l= [1..1000000]</div><div>ghci&gt; foldl&#39; (+) 0 l</div>
<div><br></div>
<div>would produce a stack overflow, since the list can not be freed, because l points to the beginning of the list</div><div>however it succeed</div><div><br></div><div>My conclussion is that, in the case of sum, with the lazy evaluation,  isnīt the list what is the cause of the stack overflow, but the lazy structure</div>

<div><br></div><div>0 + 1 +2 + 3 +4....</div><div><br></div><div>created by foldl before the final evaluation</div><div><br></div><div>I tried to test how I can force a stack overflow, in the strict case. Since foldl&#39; is strict,  the only way is to create a long long initial list. </div>

<div><br></div><div><div>ghci&gt; let l= [1..100000000]  -- 100 times larger, two 0&#39;s added</div><div>ghci&gt; foldl&#39; (+) 0 l</div><div><br></div><div>as in the previous case, l will not garbage collect, and foldl&#39; must build the real list [1,2,3,4..]  . at the end perhaps a stack overflow willl be produced</div>

<div><br></div><div>This is not the case in my windows system.ghc 6.10.1.   instead of that, ghci grow to gigabyte size and more. I stopped the process or my machine would be irresponsive. </div><div><br></div><div>My question is: Why the process does not grow also in the lazy case and instead produces a stack overflow inmediately?</div>

<div><br></div><div>Yes I know that all of this is bizantine since strictness analysis would solve this when compiled, but I think that there are somethig that i donīt understand.</div><div><br></div><div> Itīs  a bug perhaps???</div>

<div><br><div class="gmail_quote">2009/6/18 Edward Kmett <span dir="ltr">&lt;<a href="mailto:ekmett@gmail.com" target="_blank">ekmett@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div></div><div class="h5">
<div class="gmail_quote"><div>On Thu, Jun 18, 2009 at 9:14 AM, Gleb Alexeyev <span dir="ltr">&lt;<a href="mailto:gleb.alexeev@gmail.com" target="_blank">gleb.alexeev@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="padding-left:1ex;margin:0px 0px 0px 0.8ex;border-left:#ccc 1px solid">
<div>Thomas Davie wrote:<br>
<blockquote class="gmail_quote" style="padding-left:1ex;margin:0px 0px 0px 0.8ex;border-left:#ccc 1px solid">No, I think it&#39;s extremely useful.  It highlights that numbers can both be lazy and strict, and that the so called &quot;useless&quot; lazy sum, is in fact, useful.<br>


<br></blockquote></div>But lazy sum should have beed defined in terms of foldr, not foldl. And foldl is not strict enough for strict sum. Therefore the current choice in the worst of both worlds. 
<div>
<div></div>
<div></div></div></blockquote>
<div> </div>
<div> </div>
</div><div>I definitely agree with that sentiment.</div>
<div> </div><font color="#888888">
<div>-Edward Kmett</div></font></div>
<br></div></div><div class="im">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">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></div></blockquote></div><br></div></div>
</div><br>