<div dir="ltr"><div class="gmail_signature"><div dir="ltr"><div>Github issue: <a href="https://github.com/haskell/containers/issues/151">https://github.com/haskell/containers/issues/151</a></div><div><br></div><div>Summary: add alterLookupWithKey :: Ord k => (k -> Maybe a -> Maybe a) -> k -> Map k a -> (Maybe a, Map k a) function to Data.Map.Lazy.</div><div><br></div><div>Details: implement alterLookupWithKey function which takes an update function, key and map, allowing to insert, delete or update a value in a Map and return updated map with a new value. </div><div><br></div><div>Motivations:</div><div><br></div><div>For insert/update/delete: same as for alter :: Ord k => (Maybe a -> Maybe a) -> k -> Map k a -> Map k a - it allows to perform insert/update/delete within single lookup.</div><div><br></div><div>For returning updated value: same as for *LookupWithKey functions - in case of update we mind be interested in the updated value. </div><div><br></div><div>For a "key" parameter: hornestly, don't know. *LookupWithKey functions are having (k -> .. ) -> k -> <a> -> Map k a -> (Maybe a, Map k a) signatures, but I don't see any reason to pass the key to the update function, because we always can capture the key in a closure if we whant to. The only reason is to respect existent conventions. Since we already have insertLookupWithKey and updateLookupWithKey functions it makes sence to implement alterLookupWithKey in the same way.</div><div><br></div><div>-- </div><div>Sincerely, Stanislav Chernichkin.</div></div></div>
</div>