Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#707 closed bug (duplicate)

foldr/build seems to be broken

Reported by: lennart@… Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.4.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


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: ==================== =
    \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( []



Change History (3)

comment:1 Changed 11 years ago by simonmar

Resolution: duplicate
Status: newclosed

Another symptom of #683, I think.

comment:2 Changed 8 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:3 Changed 8 years ago by simonmar

Operating System: UnknownUnknown/Multiple
Note: See TracTickets for help on using tickets.