[Haskell-cafe] sum $ map f xs ... ghc-7.10 performance regression?

Thomas Koster tkoster at gmail.com
Tue Dec 15 23:06:48 UTC 2015


On Tue, Dec 15, 2015 at 1:15 AM, Thomas Koster <tkoster at gmail.com> wrote:
> Phil, I think that was true in 7.8, but if I'm reading the haddocks
> correctly, Data.List.sum = Data.Foldable.sum in 7.10, and
> Data.Foldable.sum uses foldMap/foldr.

On 15 December 2015 at 19:11, Phil Ruffwind <rf at rufflewind.com> wrote:
> According to the source code for base-4.8 (GHC 7.10), sum is
> specialized to GHC.List.sum for lists.
>
> https://hackage.haskell.org/package/base-4.8.1.0/docs/src/Data.Foldable.html#Foldable

My mistake. I didn't read past this:

class Foldable t where
  foldMap f = foldr (mappend . f) mempty
  sum = getSum #. foldMap Sum

instance Foldable [] where
  foldr = List.foldr

--
Thomas Koster


More information about the Haskell-Cafe mailing list