From af8a9b318208dea5ffa0a42d26ecb234716702f1 Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Wed, 21 Sep 2022 15:59:08 +0300 Subject: [PATCH] Add changelog and since annotations for KeyMap.insertWith --- changelog.md | 1 + src/Data/Aeson/KeyMap.hs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/changelog.md b/changelog.md index 2b65fbfd0..cb9934c27 100644 --- a/changelog.md +++ b/changelog.md @@ -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. diff --git a/src/Data/Aeson/KeyMap.hs b/src/Data/Aeson/KeyMap.hs index a6ccaecc3..2d9c8018c 100644 --- a/src/Data/Aeson/KeyMap.hs +++ b/src/Data/Aeson/KeyMap.hs @@ -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)) @@ -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))