Conversation
Add the upsert function for compatibility with containers, which added upsert in PR #1145. The function updates the value at a key or inserts a value if the key is not in the map: upsert :: Hashable k => (Maybe v -> v) -> k -> HashMap k v -> HashMap k v This fills a gap in the family of map-modifying functions: - adjust: (a -> a) - updates existing value only - update: (a -> Maybe a) - update or delete - upsert: (Maybe a -> a) - insert or update (always returns a value) - alter: (Maybe a -> Maybe a) - insert, update, or delete Closes #549. Assisted-by: GLM-5 via Fireworks AI <noreply@fireworks.ai>
The upsert and fromListUpsert functions are not yet in a released containers version. Fetch containers from git to enable model-based testing. Assisted-by: GLM-5 via Fireworks AI <noreply@fireworks.ai>
Add fromListUpsert for compatibility with containers, which added it in PR #1190: fromListUpsert :: Hashable k => (a -> Maybe v -> v) -> [(k, a)] -> HashMap k v This builds a map from a list, using the provided function to combine values. Equivalent to performing an upsert for each key/value pair. Assisted-by: GLM-5 via Fireworks AI <noreply@fireworks.ai>
Checking for pointer equality seems futile too
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #549.