<div>I&#39;ve came upon very a strange situation with memory consumption. The smallest test case I&#39;ve been able to come up with is the following:</div><div><br></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><div>

import Data.List</div><div><br></div><div>wtf d = head . dropWhile (&lt; 10^100) . map (*d) $ enumFrom 2</div><div><br></div><div>main = do</div><div>    print $ wtf 1</div><div>    print $ wtf 2 -- Everything is ok without this line</div>

</font></div></div><div><br></div><div>Expected result is that program runs in constant space. What really happening is that the program consumes memory until killed.</div><div>If second call to wtf is removed, memory usage stays constant while the program is working.</div>

<div><br></div><div>The problem is in that list returned from enumFrom is being saved between calls to wtf.</div><div><br></div><div>Is there any way to overcome this?</div><div><br></div><div>--</div><div>Regards,</div>
<div>
Petr</div><br>