module Data.Aeson.KeyMap.Extended
  ( mapWithKey,
  )
where

import Data.Aeson.Key (Key)
import Data.Aeson.KeyMap (KeyMap, traverseWithKey)
import Data.Functor.Identity
import Hasura.Prelude

mapWithKey :: (Key -> v1 -> v2) -> KeyMap v1 -> KeyMap v2
mapWithKey :: (Key -> v1 -> v2) -> KeyMap v1 -> KeyMap v2
mapWithKey Key -> v1 -> v2
f KeyMap v1
km = Identity (KeyMap v2) -> KeyMap v2
forall a. Identity a -> a
runIdentity (Identity (KeyMap v2) -> KeyMap v2)
-> Identity (KeyMap v2) -> KeyMap v2
forall a b. (a -> b) -> a -> b
$ (Key -> v1 -> Identity v2) -> KeyMap v1 -> Identity (KeyMap v2)
forall (f :: * -> *) v1 v2.
Applicative f =>
(Key -> v1 -> f v2) -> KeyMap v1 -> f (KeyMap v2)
traverseWithKey (\Key
k v1
v -> v2 -> Identity v2
forall a. a -> Identity a
Identity (Key -> v1 -> v2
f Key
k v1
v)) KeyMap v1
km