Skip to content

Commit 7a052e8

Browse files
committed
Refactor !? operator to have definition only once
Add changelog, since annotation and bump version.
1 parent 6226dc0 commit 7a052e8

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

aeson.cabal

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: aeson
2-
version: 2.1.0.0
3-
x-revision: 2
2+
version: 2.1.1.0
43
license: BSD3
54
license-file: LICENSE
65
category: Text, Web, JSON

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
For the latest version of this document, please see [https://github.com/haskell/aeson/blob/master/changelog.md](https://github.com/haskell/aeson/blob/master/changelog.md).
22

3+
### 2.1.1.0
4+
5+
- Add `Data.Aeson.KeyMap.!?` (flipped) alias to `Data.Aeson.KeyMap.lookup`.
6+
37
### 2.1.0.0
48

59
- Change time instances of types with year (`Day`, `UTCTime`) to require years with at least 4 digits.

src/Data/Aeson/KeyMap.hs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,6 @@ alterF f k m = fmap g (f mv) where
185185
lookup :: Key -> KeyMap v -> Maybe v
186186
lookup t tm = M.lookup t (unKeyMap tm)
187187

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-
196188
-- | Associate the specified value with the specified key
197189
-- in this map. If this map previously contained a mapping
198190
-- for the key, the old value is replaced.
@@ -396,14 +388,6 @@ alterF f k = fmap KeyMap . H.alterF f k . unKeyMap
396388
lookup :: Key -> KeyMap v -> Maybe v
397389
lookup t tm = H.lookup t (unKeyMap tm)
398390

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-
407391
-- | Associate the specified value with the specified key
408392
-- in this map. If this map previously contained a mapping
409393
-- for the key, the old value is replaced.
@@ -566,6 +550,16 @@ mapMaybeWithKey f (KeyMap m) = KeyMap (H.mapMaybeWithKey f m)
566550
-- combinators using existing abstractions
567551
-------------------------------------------------------------------------------
568552

553+
-- | Return the value to which the specified key is mapped,
554+
-- or Nothing if this map contains no mapping for the key.
555+
--
556+
-- This is a flipped version of 'lookup'.
557+
--
558+
-- @since 2.1.1.0
559+
--
560+
(!?) :: KeyMap v -> Key -> Maybe v
561+
(!?) m k = lookup k m
562+
569563
-- | Generalized union with combining function.
570564
alignWith :: (These a b -> c) -> KeyMap a -> KeyMap b -> KeyMap c
571565
alignWith f (KeyMap x) (KeyMap y) = KeyMap (SA.alignWith f x y)

0 commit comments

Comments
 (0)