Strict foldl

Ch. A. Herrmann herrmann@infosun.fmi.uni-passau.de
Fri, 7 Dec 2001 10:34:05 +0100


Hi Manuel,

    >> PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND 23542
    >> herrmann 20 0 250M 130M 97500 R 66.3 52.4 0:21 ghc-5.02

    Manuel> Is this what I think it is?  Do you benchmark the
    Manuel> interpreter?  Interpreted code isn't optimised.

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 make it simpler for you.

However, the sum computation based on my sfold definition did not
take too long even with the interpreter. Thus, I wondered why
the predefined sum computation behaves that bad.

    Manuel> GHC's Prelude does not define `sum' in terms of foldl;
    Manuel> instead, it uses the definition ...

Where can I find the ghc prelude?
Is there also the definition of the mysterious foldl' function
which I saw from time to time before it disappeared again?   

    Manuel> I haven't checked the Core code produced for the above
    Manuel> definition, but as I know GHC, I am pretty sure that it
    Manuel> compiles the Prelude definition into a nice tight loop
    Manuel> making use of all available strictness.

One would expect that ghci uses a compiled version 
of sum. Does it or not?

Cheers
--
 Christoph