Opened 8 years ago

Closed 8 years ago

Last modified 6 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: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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): []

....

-}

Change History (3)

comment:1 Changed 8 years ago by simonmar

  • Resolution set to duplicate
  • Status changed from new to closed

Another symptom of #683, I think.

comment:2 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:3 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.