Skip to content

One function missing in Data.Map

Isn't the function adjustLookupWithKey missing in Data.Map? There are functions ending in LookupWithKey for both insert and update but not for adjust.

adjustLookupWithKey :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> (Maybe a, Map k a)

adjustLookupWithKey f k m[[BR]]

==> (Nothing, m) if k is not in m[[BR]] ==> (Just old, m) if f x is Nothing[[BR]] ==> (Just new, m') if f x is Just new, and m' being m adjusted

The same behavior could be simulated using library function and user defined function, but I it deserves an implementation.

Trac metadata
Trac field Value
Version 6.12.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries (other)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information