lens-aeson 1.1.1 → 1.1.2
raw patch · 3 files changed
+51/−7 lines, 3 filesdep ~aesonPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson
API changes (from Hackage documentation)
+ Data.Aeson.Lens: instance Control.Lens.At.At (Data.Aeson.KeyMap.KeyMap v)
+ Data.Aeson.Lens: instance Control.Lens.At.Ixed (Data.Aeson.KeyMap.KeyMap v)
+ Data.Aeson.Lens: instance Control.Lens.Each.Each (Data.Aeson.KeyMap.KeyMap a) (Data.Aeson.KeyMap.KeyMap b) a b
Files
- CHANGELOG.markdown +6/−0
- lens-aeson.cabal +8/−5
- src/Data/Aeson/Lens.hs +37/−2
CHANGELOG.markdown view
@@ -1,3 +1,9 @@+1.1.2 [2021.10.09]+------------------+* Allow building with `aeson-2.0.0.0`.+* Add `Index`, `IxValue`, `Ixed`, `At`, and `Each` instances for `KeyMap` if+ building with `aeson-2.0.0.0` or later.+ 1.1.1 [2021.02.17] ------------------ * Allow building with `lens-5.*`.
lens-aeson.cabal view
@@ -1,6 +1,6 @@ name: lens-aeson category: Numeric-version: 1.1.1+version: 1.1.2 license: MIT cabal-version: >= 1.10 license-file: LICENSE@@ -21,8 +21,9 @@ , GHC == 8.2.2 , GHC == 8.4.4 , GHC == 8.6.5- , GHC == 8.8.3- , GHC == 8.10.1+ , GHC == 8.8.4+ , GHC == 8.10.4+ , GHC == 9.0.1 synopsis: Law-abiding lenses for aeson description: Law-abiding lenses for aeson. @@ -45,9 +46,11 @@ text >= 0.11.1.10 && < 1.3, vector >= 0.9 && < 0.13, unordered-containers >= 0.2.3 && < 0.3,- attoparsec >= 0.10 && < 0.14,+ attoparsec >= 0.10 && < 0.15, bytestring >= 0.9 && < 0.12,- aeson >= 0.7.0.5 && < 1.6,+ -- TODO: Eventually, we should bump the lower version bounds to >=2 so that+ -- we can remove some CPP in Data.Aeson.Lens. See #38.+ aeson >= 0.7.0.5 && < 2.1, scientific >= 0.3.2 && < 0.4 exposed-modules:
src/Data/Aeson/Lens.hs view
@@ -73,6 +73,11 @@ import Data.Vector (Vector) import Prelude hiding (null) +#if MIN_VERSION_aeson(2,0,0)+import qualified Data.Aeson.Key as Key+import qualified Data.Aeson.KeyMap as KM+#endif+ -- $setup -- >>> import Control.Lens -- >>> import Data.Aeson@@ -296,7 +301,15 @@ -- >>> _Object._Wrapped # [("key" :: Text, _String # "value")] :: String -- "{\"key\":\"value\"}" _Object :: Prism' t (HashMap Text Value)- _Object = _Value.prism Object (\v -> case v of Object o -> Right o; _ -> Left v)+ _Object = _Value.prism (Object . fwd) (\v -> case v of Object o -> Right (bwd o); _ -> Left v)+ where+#if MIN_VERSION_aeson(2,0,0)+ fwd = KM.fromHashMapText+ bwd = KM.toHashMapText+#else+ fwd = id+ bwd = id+#endif {-# INLINE _Object #-} -- |@@ -472,7 +485,14 @@ type instance IxValue Value = Value instance Ixed Value where- ix i f (Object o) = Object <$> ix i f o+ ix i f (Object o) = Object <$> ix (toKey i) f o+ where+#if MIN_VERSION_aeson(2,0,0)+ toKey :: Text -> Key.Key+ toKey = Key.fromText+#else+ toKey = id+#endif ix _ _ v = pure v {-# INLINE ix #-} @@ -481,6 +501,21 @@ plate f (Array a) = Array <$> traverse f a plate _ xs = pure xs {-# INLINE plate #-}++#if MIN_VERSION_aeson(2,0,0)+type instance Index (KM.KeyMap v) = Key.Key+type instance IxValue (KM.KeyMap v) = v++instance Ixed (KM.KeyMap v)++instance At (KM.KeyMap v) where+ at k f = KM.alterF f k+ {-# INLINE at #-}++instance Each (KM.KeyMap a) (KM.KeyMap b) a b where+ each = traversed+ {-# INLINE each #-}+#endif ------------------------------------------------------------------------------ -- Pattern Synonyms