Skip to content

Monadic folds #678

Open
Open
@sjakobi

Description

@sjakobi

I just needed the following function, which turned out a bit trickier than I had expected:

foldlWithKeyM :: (Ord k, Monad m) => (k -> b -> a -> m b) -> b -> Map k a -> m b
foldlWithKeyM f z0 m = foldrWithKey f' return m z0
  where f' k x g z = f k z x >>= g

Maybe it should be included in containers?

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