On Mon, 15 Jun 2009, Don Stewart wrote:
keithshep:
The answer is sometimes (only if you use an optimize flag):
You're turning on the strictness analyser. That's enabled with -O or
-O2.
But sum should be using a tail recursive foldl'. It's a bug in the H98
report, IMO.
I can wrap an accumulator lazily:
data Accum a = Accum a
Then foldl' using (Accum a) instead of 'a' would be non-strict, again.
Thus foldl' is not always strict. I think this 'seq' function is broken
and there should have been a Seq class. Then you can choose the required
depth of strictness.
Btw. for lazy Peano numbers, sum would be better a foldr rather than
foldl.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe