Skip to content

foldl' and foldr' for Seq are not strict in the starting value #1072

@meooow25

Description

@meooow25

This is unlike every other structure we have.

λ> import qualified Data.Foldable as F
λ> import qualified Data.Set as S -- or Map or IntSet or IntMap
λ> F.foldl' (\_ _ -> ()) undefined (S.singleton ())
*** Exception: Prelude.undefined
CallStack (from HasCallStack):
  ...
λ> F.foldr' (\_ _ -> ()) undefined (S.singleton ())
*** Exception: Prelude.undefined
  ...
λ> import qualified Data.Sequence as Seq
λ> F.foldl' (\_ _ -> ()) undefined (Seq.singleton ())
()
λ> F.foldr' (\_ _ -> ()) undefined (Seq.singleton ())
()

I think we should make these strict.

Perhaps it's worth mentioning that for lists, foldl' is strict in the starting value but foldr' is not (GHC #25508).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions