Re: Strict foldl

2001-12-07 Thread Jan Kort
"Ch. A. Herrmann" wrote: > > Hi Haskellers, > > which compiler settings do I have to pass to ghc-5.02 > in order to achieve that the strictness analyzer > recognizes strictness of (+) in foldl and computes > sum in constant space? > > Prelude> sum [1.

RE: Strict foldl

2001-12-07 Thread Julian Seward (Intl Vendor)
| > Prelude> sum [1..1000] | > | > had the following effect: | > | > PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND | > 23542 herrmann 20 0 250M 130M 97500 R66.3 52.4 0:21 ghc-5.02 | | Is this what I think it is? Do you benchmark the | interpreter? Interpr

Re: Strict foldl

2001-12-07 Thread Ch. A. Herrmann
not really. I wanted to have a strict foldl (for a different purpose than sum) and could not figure out how to tell the compiler. I tried different things, precompile just one module, compile the entire program, using -fglasgow-exts, but nothing seems to work. Thus, I reduced the problem to sum to

Re: Strict foldl

2001-12-06 Thread Manuel M. T. Chakravarty
Hal Daume III <[EMAIL PROTECTED]> wrote, > > Is this what I think it is? Do you benchmark the > > interpreter? Interpreted code isn't optimised. When I > > compile > > > > main = print $ sum [1..1000] > > > > with -O2, it takes 13s on a 600MHz P3 and runs in 1.5MB of > > space. > > O

Re: Strict foldl

2001-12-06 Thread Hal Daume III
Hi, > Is this what I think it is? Do you benchmark the > interpreter? Interpreted code isn't optimised. When I > compile > > main = print $ sum [1..1000] > > with -O2, it takes 13s on a 600MHz P3 and runs in 1.5MB of > space. Out of curiousity, why doesn't this get compiled down to

Re: Strict foldl

2001-12-06 Thread Manuel M. T. Chakravarty
"Ch. A. Herrmann" <[EMAIL PROTECTED]> wrote, > which compiler settings do I have to pass to ghc-5.02 > in order to achieve that the strictness analyzer > recognizes strictness of (+) in foldl and computes > sum in constant space? > > Prelude> sum [1..10

Strict foldl

2001-12-06 Thread Ch. A. Herrmann
Hi Haskellers, which compiler settings do I have to pass to ghc-5.02 in order to achieve that the strictness analyzer recognizes strictness of (+) in foldl and computes sum in constant space? Prelude> sum [1..1000] had the following effect: PID USER PRI NI SIZE RSS SHARE S

foldl'

2001-07-28 Thread Jon Fairbairn
Unless I'm mistaken, foldl' (the strict version of foldl) doesn't appear in (the export list of) the standard prelude or the list library. Is there a good reason for this? New users quite quickly find that they need it. Jón -- Jón Fairbairn [

Re: foldl, tail recursion, and strictness (was: stack overflow)

2001-02-26 Thread George Russell
I know it's complete heresy to say so, but I use laziness very little in Haskell, while I probably pay quite a lot for it in CPU time and memory, because of all those thunks which have to be stored. However I prefer Haskell's type classes, syntax and purity to, say, Standard ML. So I wonder whet

Re: foldl, tail recursion, and strictness (was: stack overflow)

2001-02-26 Thread Ketil Malde
"C.Reinke" <[EMAIL PROTECTED]> writes: > So foldl is indeed tail recursive, but this doesn't help if its > operator isn't strict because the tail recursion only builds up the > expression to be evaluated. Making strictness explicit by defining a > variant o

foldl, tail recursion, and strictness (was: stack overflow)

2001-02-26 Thread C.Reinke
"Julian Assange" <[EMAIL PROTECTED]>: > .. > | When used with a 170k input file, makemap suffers from a stack > | overflow. foldl should be tail recursive. What's the score? "Simon Peyton-Jones" <[EMAIL PROTECTED]>: > Consider >

One function for foldr, foldl, zip, union, etc...

1999-07-07 Thread Kevin Atkinson
functions (foldr, foldl, zip, union, etc) in terms of foldl or foldr in really, as shown in a previous post, this is horribly inefficient. It seams like my Generator concept, which I just posted 2 days ago, would be a good way to go because GHC is able to optimize away any garbage collection when

Re: The cost of defining foldl w/ foldr and vis versa

1999-07-03 Thread Kevin Atkinson
Kevin Atkinson wrote: > > Even though it is possible to define foldl with foldr or vis versa it > (with the current implantation of Haskell with ghc) not nearly as > efficient. To demonstrate this consider folding of a range. > > import System > > foldR f i (a,z) =

The cost of defining foldl w/ foldr and vis versa

1999-07-02 Thread Kevin Atkinson
Even though it is possible to define foldl with foldr or vis versa it (with the current implantation of Haskell with ghc) not nearly as efficient. To demonstrate this consider folding of a range. import System foldR f i (a,z) = g a where g a | a == z= i | otherwise = f a

foldl, unneeded laziness

1998-06-29 Thread S.D.Mechveliani
S. Alexander Jacobson <[EMAIL PROTECTED]> wrote (sorry, i do not remember, to which of the Haskell lists) > Wow! If Ralf is right, then foldl in a lazy language always generates > a space leak and should be avoided in favor of strictFoldl. > ... There were other letters o

foldM vs. foldL and foldR

1997-02-02 Thread Tommy Thorn
Please, could anybody explain me what the rationale behind the current foldM in Monad? At least of the IO monad, it seems important to have a left associative fold instead of the right associative foldM. Adding to my confusion, it seems that earlier in time, there was indeed two monad fold's inst