[Haskell-cafe] curious about sum

Jake McArthur jake.mcarthur at gmail.com
Sat Jun 13 16:18:47 EDT 2009

Keith Sheppard wrote:
> Is there any reason that sum isn't strict? I can't think of any case
> where that is a good thing.
> Prelude> sum [0 .. 1000000]
> *** Exception: stack overflow

As others have said, there are cases where non-strictness is what you 
want. And if you are using a type that is strict (the common case), 
GHC's optimizations will catch it.

The historical reason for this is that foldl' is not Haskell 98, only foldl.

- Jake

More information about the Haskell-Cafe mailing list