packages feed

aeson-lens 0.4.0.1 → 0.4.1.0

raw patch · 2 files changed

+22/−13 lines, 2 filesdep ~lensPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: lens

API changes (from Hackage documentation)

+ Data.Aeson.Lens: ArrIx :: Int -> ValueIx
+ Data.Aeson.Lens: ObjIx :: Text -> ValueIx
+ Data.Aeson.Lens: data ValueIx
+ Data.Aeson.Lens: valueAt :: (FromJSON u, ToJSON v) => ValueIx -> IndexedLens ValueIx (Maybe Value) (Maybe Value) (Maybe u) (Maybe v)

Files

Data/Aeson/Lens.hs view
@@ -15,14 +15,17 @@    -- * Traversals   traverseArray, traverseArray',-  traverseObject, traverseObject'+  traverseObject, traverseObject',++  -- * Generic Indexing+  ValueIx(..),+  valueAt,   ) where  import           Control.Applicative import           Control.Lens import           Data.Aeson import qualified Data.HashMap.Strict as HMS-import           Data.List.Lens import           Data.Maybe import           Data.Monoid import qualified Data.Text           as T@@ -56,7 +59,7 @@ updateV :: Int -> Value -> V.Vector Value -> V.Vector Value updateV i v a   | i >= V.length a =-    updateV i v $ V.generate (i + 1) $ \ii -> fromMaybe Null $ a `V.indexM` ii+    updateV i v $ V.generate (i + 1) $ \ii -> fromMaybe Null $ a V.!? ii   | otherwise =     a V.// [(i, v)] {-# INLINE updateV #-}@@ -78,15 +81,21 @@ -- Nothing -- >>> v ^. nth 0 :: Maybe Value -- Nothing--- >>> let x = nth 0 .~ Just 1 $ Nothing+-- >>> let x = Nothing & nth 0 .~ Just 1 -- >>> L.unpack $ encode x -- "[1]"--- >>> let y = nth 1 .~ Just "hoge" $ x+-- >>> let y = x & nth 1 .~ Just "hoge" -- >>> L.unpack $ encode y -- "[1,\"hoge\"]"--- >>> let z = nth 0 .~ Just False $ y+-- >>> let z = y & nth 0 .~ Just False -- >>> L.unpack $ encode z -- "[false,\"hoge\"]"+--+-- >>> let v = decode (L.pack "[]") :: Maybe Value+-- >>> v & nth 0 .~ Just "hello"+-- Just (Array (fromList [String "hello"]))+-- >>> v & nth 1 .~ Just "hello"+-- Just (Array (fromList [Null,String "hello"]))  nth :: (FromJSON v, ToJSON v)        => Int@@ -111,10 +120,10 @@ -- Nothing -- >>> v ^. key (T.pack "hoge") :: Maybe Value -- Nothing--- >>> let w = key (T.pack "a") .~ Just 2.23 $ Nothing+-- >>> let w = Nothing & key (T.pack "a") .~ Just 2.23 -- >>> L.unpack $ encode w -- "{\"a\":2.23}"--- >>> let x = key (T.pack "b") . key (T.pack "c") .~ Just True $ w+-- >>> let x = w & key (T.pack "b") . key (T.pack "c") .~ Just True -- >>> L.unpack $ encode x -- "{\"b\":{\"c\":true},\"a\":2.23}" key :: (FromJSON v, ToJSON v)@@ -132,10 +141,10 @@ -- | Indexed traversal of Array -- -- >>> let v = decode (L.pack "[1, true, null]") :: Maybe Value--- >>> catMaybes . toListOf traverseArray $ v :: [Value]+-- >>> v & catMaybes . toListOf traverseArray :: [Value] -- [Number 1,Bool True,Null] -- >>> let w = decode (L.pack "[{\"name\": \"tanakh\", \"age\": 29}, {\"name\": \"nushio\", \"age\": 28}]") :: Maybe Value--- >>> catMaybes . toListOf (traverseArray . key (T.pack "name")) $ w :: [T.Text]+-- >>> w & catMaybes . toListOf (traverseArray . key (T.pack "name")) :: [T.Text] -- ["tanakh","nushio"] traverseArray :: (FromJSON v, ToJSON v)                  => SimpleIndexedTraversal Int (Maybe Value) (Maybe v)@@ -154,7 +163,7 @@ -- | Indexed traversal of Object -- -- >>> let w = decode (L.pack "[{\"name\": \"tanakh\", \"age\": 29}, {\"name\": \"nushio\", \"age\": 28}]") :: Maybe Value--- >>> catMaybes . toListOf (traverseArray . traverseObject) $ w :: [Value]+-- >>> w & catMaybes . toListOf (traverseArray . traverseObject) :: [Value] -- [String "tanakh",Number 29,String "nushio",Number 28] traverseObject :: (FromJSON v, ToJSON v)                   => SimpleIndexedTraversal T.Text (Maybe Value) (Maybe v)
aeson-lens.cabal view
@@ -1,5 +1,5 @@ name:                aeson-lens-version:             0.4.0.1+version:             0.4.1.0 synopsis:            Lens of Aeson description:         Lens of Aeson license:             BSD3@@ -19,7 +19,7 @@   exposed-modules:     Data.Aeson.Lens   build-depends:       base >=4.5 && <5                      , aeson >=0.6-                     , lens >=3.3+                     , lens >=3.6                      , text >=0.11                      , bytestring >=0.9                      , vector >=0.9