@@ -16,6 +16,7 @@ module Data.Aeson.KeyMap (
16
16
-- * Query
17
17
null ,
18
18
lookup ,
19
+ (!?) ,
19
20
size ,
20
21
member ,
21
22
@@ -184,6 +185,14 @@ alterF f k m = fmap g (f mv) where
184
185
lookup :: Key -> KeyMap v -> Maybe v
185
186
lookup t tm = M. lookup t (unKeyMap tm)
186
187
188
+ -- | Return the value to which the specified key is mapped,
189
+ -- or Nothing if this map contains no mapping for the key.
190
+ --
191
+ -- This is a flipped version of 'lookup'.
192
+ --
193
+ (!?) :: KeyMap v -> Key -> Maybe v
194
+ (!?) m k = lookup k m
195
+
187
196
-- | Associate the specified value with the specified key
188
197
-- in this map. If this map previously contained a mapping
189
198
-- for the key, the old value is replaced.
@@ -387,6 +396,14 @@ alterF f k = fmap KeyMap . H.alterF f k . unKeyMap
387
396
lookup :: Key -> KeyMap v -> Maybe v
388
397
lookup t tm = H. lookup t (unKeyMap tm)
389
398
399
+ -- | Return the value to which the specified key is mapped,
400
+ -- or Nothing if this map contains no mapping for the key.
401
+ --
402
+ -- This is a flipped version of 'lookup'.
403
+ --
404
+ (!?) :: KeyMap v -> Key -> Maybe v
405
+ (!?) m k = lookup k m
406
+
390
407
-- | Associate the specified value with the specified key
391
408
-- in this map. If this map previously contained a mapping
392
409
-- for the key, the old value is replaced.
0 commit comments