[GHC] #2621: sum and product thunkpile

GHC trac at galois.com
Mon Sep 22 23:23:12 EDT 2008


#2621: sum and product thunkpile
----------------------------+-----------------------------------------------
    Reporter:  Bart Massey  |       Owner:                
        Type:  bug          |      Status:  new           
    Priority:  normal       |   Component:  libraries/base
     Version:  6.9          |    Severity:  major         
    Keywords:               |    Testcase:                
Architecture:  Multiple     |          Os:  Multiple      
----------------------------+-----------------------------------------------
 Do "ulimit -v 524288" at the shell so your machine won't hang. Run ghci,
 bring in Data.List, and execute "sum [1..10**8]".  Notice that you run out
 of memory.  Now try again with "foldl1' (+) [1..10**8]".  Note that you
 get an answer.

 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.

 This kind of bug is grim for new users, which is why the severity is
 marked "major".

 Patch attached.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2621>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list