[GHC] #707: foldr/build seems to be broken

GHC trac at galois.com
Mon Feb 27 10:58:22 EST 2006


#707: foldr/build seems to be broken
---------------------------------------+------------------------------------
    Reporter:  lennart at augustsson.net  |        Owner:         
        Type:  bug                     |       Status:  new    
    Priority:  normal                  |    Milestone:         
   Component:  Compiler                |      Version:  6.4.1  
    Severity:  normal                  |     Keywords:         
          Os:  Unknown                 |   Difficulty:  Unknown
Architecture:  Unknown                 |  
---------------------------------------+------------------------------------
Reading the documentation for ghc it says that if a good consumer meets a
 good producer the intermediate list will disappear.  List enumeration is s
 good producer, and length is a good consumer, so there should be no
 intermediate list between these.

 Looking at the example below, it sure looks like a list is generated.

 {{{

 module CG1 where

 foo :: Int -> Int
 foo n = length [1..n]

 -- Compile with
 -- ghc -v5 -ddump-simpl-stats -ddump-rules -O2 -S CG1.hs

 -- Output from this compilation
 {-
 Glasgow Haskell Compiler, Version 6.4.1, for Haskell 98, compiled by GHC
 version 6.4

 ....

 ==================== STG syntax: ====================
 CG1.foo =
     \r [n_s1Ah]
         case n_s1Ah of wild1_s1Ap {
           GHC.Base.I# y_s1Ak ->
               case GHC.Enum.eftInt 1 y_s1Ak of sat_s1Am {
                 __DEFAULT ->
                     case GHC.List.$wlen sat_s1Am 0 of ww_s1Ao {
                       __DEFAULT -> GHC.Base.I# [ww_s1Ao];
                     };
               };
         };
 SRT(CG1.foo): []

 ....

 -}

 }}}

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


More information about the Glasgow-haskell-bugs mailing list