HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleaeson-2.2.3.0Haskell2010

Data.Aeson.KeyMap

An abstract interface for maps from JSON keys to values.

  • 2 types
  • 51 values
  • Packageaeson-2.2.3.0
  • Exports53
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceKeyMap.hs

Map Type

1 declaration
newtypenewtype KeyMap v
#

A map from JSON key type Key to v.

Instances37Functor, Foldable, Traversable, Arbitrary1, Align, Semialign, …

Query

5 declarations
valuelookup :: Key -> KeyMap v -> Maybe v
#

Return the value to which the specified key is mapped, or Nothing if this map contains no mapping for the key.

value(!?) :: KeyMap v -> Key -> Maybe v
#

Return the value to which the specified key is mapped, or Nothing if this map contains no mapping for the key.

This is a flipped version of lookup.

valuesize :: KeyMap v -> Int
#

Return the number of key-value mappings in this map.

Construction

2 declarations

Insertion

valueinsert :: Key -> v -> KeyMap v -> KeyMap v
#

Associate the specified value with the specified key in this map. If this map previously contained a mapping for the key, the old value is replaced.

valueinsertWith :: (a -> a -> a) -> Key -> a -> KeyMap a -> KeyMap a
#

Insert with a function combining new and old values, taken in that order.

Deletion

1 declaration
valuedelete :: Key -> KeyMap v -> KeyMap v
#

Remove the mapping for the specified key from this map if present.

Update

1 declaration

Combine

9 declarations

Lists

5 declarations
valuefromList :: [(Key, v)] -> KeyMap v
#

Construct a map with the supplied mappings. If the list contains duplicate mappings, the later mappings take precedence.

Example1 expression
fromList [("a", 'x'), ("a", 'y')]fromList [("a",'y')]
valuefromListWith :: (v -> v -> v) -> [(Key, v)] -> KeyMap v
#

Construct a map from a list of elements. Uses the provided function, f, to merge duplicate entries with (f newVal oldVal).

valuetoList :: KeyMap v -> [(Key, v)]
#

Return a list of this map's keys and elements.

The order is not stable. Use toAscList for stable ordering.

valuetoAscList :: KeyMap v -> [(Key, v)]
#

Return a list of this map's elements in ascending order based of the textual key.

valueelems :: KeyMap v -> [v]
#

Return a list of this map' elements.

Maps

10 declarations

Traversal

0 declarations

Map

valuemap :: (a -> b) -> KeyMap a -> KeyMap b
#

Map a function over all values in the map.

Folds

6 declarations
valuefoldrWithKey :: (Key -> v -> a -> a) -> a -> KeyMap v -> a
#

Reduce this map by applying a binary operator to all elements, using the given starting value (typically the right-identity of the operator).

Conversions

1 declaration

Filter

4 declarations

Key Type

1 declaration
newtypenewtype Key
#
Instances27Eq, Data, Ord, Read, Show, IsString, …