Ticket #92 (new defect)

Opened 4 months ago

foldl' within Foldable instance seems broken

Reported by: MikeIzbicki Owned by:
Priority: major Milestone:
Version: Keywords: performance
Cc:

Description

When I run this piece of code:

import qualified Data.Vector as V
import qualified Data.Foldable as F
size=10^8
main = do
    print $ (V.foldl (+) 0 $ (V.enumFromN (0::Double) size) :: Double)
    print $ (V.foldl' (+) 0 $ (V.enumFromN (0::Double) size) :: Double)
    print $ (F.foldl (+) 0 $ (V.enumFromN (0::Double) size) :: Double)
    print $ (F.foldl' (+) 0 $ (V.enumFromN (0::Double) size) :: Double)
    putStrLn "done."

The first three numbers print almost instantly, but the last number takes forever to print. The profiler is telling me that the garbage collector is going off like mad. Shouldn't F.foldl' be the exact same thing as V.foldl'?

Note: See TracTickets for help on using tickets.