Skip to content

Commit

Permalink
Add changelog and since annotations for KeyMap.insertWith
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed Sep 21, 2022
1 parent b0ea719 commit af8a9b3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ For the latest version of this document, please see [https://github.com/haskell/
### 2.1.1.0

- Add `Data.Aeson.KeyMap.!?` (flipped) alias to `Data.Aeson.KeyMap.lookup`.
- Add `Data.Aeson.KeyMap.insertWith` function.
- Use `unsafeDupablePerformIO` instead of incorrect `accursedUnutterablePerformIO` in creation of keys in TH serialisation.
This fixes a bug in TH deriving, e.g. when `Strict` pragma was enabled.

Expand Down
2 changes: 2 additions & 0 deletions src/Data/Aeson/KeyMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ insert k v tm = KeyMap (M.insert k v (unKeyMap tm))

-- | Insert with a function combining new and old values, taken in that order.
--
-- @since 2.1.1.0
insertWith :: (a -> a -> a) -> Key -> a -> KeyMap a -> KeyMap a
insertWith f k v m = KeyMap (M.insertWith f k v (unKeyMap m))

Expand Down Expand Up @@ -402,6 +403,7 @@ insert k v tm = KeyMap (H.insert k v (unKeyMap tm))

-- | Insert with a function combining new and old values, taken in that order.
--
-- @since 2.1.1.0
insertWith :: (a -> a -> a) -> Key -> a -> KeyMap a -> KeyMap a
insertWith f k v m = KeyMap (H.insertWith f k v (unKeyMap m))

Expand Down

0 comments on commit af8a9b3

Please sign in to comment.