GHC: Ticket #2621: sum and product thunkpile
http://ghc.haskell.org/trac/ghc/ticket/2621
<p>
Do "ulimit -v 524288" at the shell so your machine won't hang. Run ghci, bring in Data.List, and execute "sum [1..10<strong>8]". Notice that you run out of memory. Now try again with "foldl1' (+) [1..10</strong>8]". Note that you get an answer.
</p>
<p>
The definition of sum and product in the Report use foldl. However, the versions currently being used are open-coded for some reason. They should just use foldl1' (after handling the special case of the empty list appropriately). As it is, the functions thunkpile; this seems pointless, as they are ultimately completely strict in their argument.
</p>
<p>
This kind of bug is grim for new users, which is why the severity is marked "major".
</p>
<p>
Patch attached.
</p>
en-usGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/ticket/2621
Trac 1.0.9simonmarTue, 23 Sep 2008 16:52:24 GMTstatus changed; difficulty, resolution set
http://ghc.haskell.org/trac/ghc/ticket/2621#comment:1
http://ghc.haskell.org/trac/ghc/ticket/2621#comment:1
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>difficulty</strong>
set to <em>Unknown</em>
</li>
<li><strong>resolution</strong>
set to <em>duplicate</em>
</li>
</ul>
<p>
resubmitted as <a class="closed ticket" href="http://ghc.haskell.org/trac/ghc/ticket/2622" title="bug: sum and product thunkpile (closed: invalid)">#2622</a>
</p>
TicketsimonmarTue, 30 Sep 2008 15:45:20 GMTarchitecture changed
http://ghc.haskell.org/trac/ghc/ticket/2621#comment:2
http://ghc.haskell.org/trac/ghc/ticket/2621#comment:2
<ul>
<li><strong>architecture</strong>
changed from <em>Multiple</em> to <em>Unknown/Multiple</em>
</li>
</ul>
TicketsimonmarTue, 30 Sep 2008 15:54:58 GMTos changed
http://ghc.haskell.org/trac/ghc/ticket/2621#comment:3
http://ghc.haskell.org/trac/ghc/ticket/2621#comment:3
<ul>
<li><strong>os</strong>
changed from <em>Multiple</em> to <em>Unknown/Multiple</em>
</li>
</ul>
Ticket