Simon Marlow wrote:
On 02 November 2005 00:20, Lennart Augustsson wrote:


Furthermore, ghc has a WRONG definition of sum.


Surely not... sum is defined by Haskell 98 as:

 sum = foldl (+) 0

and this is exactly what GHC provides.  Furthermore we have specialised
strict versions for Int and Integer.

Also, we shouldn't be turning overloaded functions into class methods
purely for the purposes of providing optimised versions; that's what the
SPECIALISE pragma is for.

You are absolutly right, sum is defined with foldl.
I wonder why my hbc prelude had it defined with foldr?
(This should teach me not to look at bit rotted code.)

        -- Lennart
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to