`sum' in ghc-4.02

1999-05-27 Thread S.D.Mechveliani
of Prelude as if it was NOT compiled from the sources of distribution. The source - src/.../PrelList.lhs says sum = foldl (+) 0 {-# SPECIALISE sum :: [Int] -> Int #-} Testing `sum' in ghc-4.02-i386-unknown-linux show

`sum' in ghc-4.02

1999-05-27 Thread S.D.Mechveliani
ghc-4.02 treats sum strangely. In the below program, sum xs needs small, constant size stack, sm xs needs stack proportional to length xs. And sm is the implementation of sum shown in src/.../PrelList.lhs I apply ghc -c -O. What keys are needed to code sum like it is in this ghc-4.0

Re: `sum' in ghc-4.02

1999-05-27 Thread Marcin 'Qrczak' Kowalczyk
Thu, 27 May 1999 04:34:30 -0700, Simon Peyton-Jones <[EMAIL PROTECTED]> pisze: > What's needed is either to inline foldl, or to have a version > that's suitable for a strict argument, such as (+). GHC currently lacks > a way to exploit such a version (side conditions on a rewrite rule?) > and do

RE: `sum' in ghc-4.02

1999-05-27 Thread Simon Peyton-Jones
> But I'm not sure why it makes a difference. Definition of foldl is > similar to sum', only with a different argument order: But the compiler can see that sum' is strict in its second argument, so it can use call by value. It can't for foldl. Simon

Re: `sum' in ghc-4.02

1999-05-27 Thread Marcin 'Qrczak' Kowalczyk
Thu, 27 May 1999 09:16:43 +0400 (MSD), S.D.Mechveliani <[EMAIL PROTECTED]> pisze: > And sm is the implementation of sum shown in src/.../PrelList.lhs ghc/lib/std/PrelList.lhs from ghc-4.02 sources: -- sum and product compute the sum or product of a finite list of numbers. {-# SPECI

RE: `sum' in ghc-4.02

1999-05-27 Thread Simon Peyton-Jones
gt; From: [EMAIL PROTECTED] > Sent: Thursday, May 27, 1999 6:17 AM > To: [EMAIL PROTECTED] > Subject: `sum' in ghc-4.02 > > > ghc-4.02 treats sum strangely. > In the below program, sum xs needs small, constant size stack, > sm xs needs stack proportional to l