[Haskell] specification of sum

Simon Marlow simonmar at microsoft.com
Wed Nov 2 06:18:13 EST 2005


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.

Cheers,
	Simon


More information about the Haskell mailing list