Skip to content

Folds over mutable vectors #326

@andrewthad

Description

@andrewthad

I noticed a reoccurring help function across several applications that I've written, and I think it would be nice to have these in vector itself:

traverse_ ::
     (a -> m b)
  -> MVector (PrimState m) a
  -> m ()

foldM :: -- Should probably be named foldlM instead as in Data.Foldable, but vector uses foldM elsewhere
     (b -> a -> m b)
  -> b
  -> MVector (PrimState m) a
  -> m b

The implementations are both straightforward, and I'm happy to implement this if others find it worthwhile. There is the possibility of a traverse that either (a) mutates the vector in-place or (b) creates a new mutable vector. There's more room to disagree there, so if anyone is interested in that, I think that discussing it on a separate issue would be better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions