packages feed

aeson 1.5.2.0 → 1.5.3.0

raw patch · 8 files changed

+233/−43 lines, 8 filesdep +data-fixdep +strictdep ~dlistdep ~quickcheck-instancesPVP ok

version bump matches the API change (PVP)

Dependencies added: data-fix, strict

Dependency ranges changed: dlist, quickcheck-instances

API changes (from Hackage documentation)

Files

Data/Aeson/Types/FromJSON.hs view
@@ -123,6 +123,10 @@ import qualified Data.Attoparsec.ByteString.Char8 as A (endOfInput, parseOnly, scientific) import qualified Data.ByteString.Lazy as L import qualified Data.DList as DList+#if MIN_VERSION_dlist(1,0,0) && __GLASGOW_HASKELL__ >=800+import qualified Data.DList.DNonEmpty as DNE+#endif+import qualified Data.Fix as F import qualified Data.HashMap.Strict as H import qualified Data.HashSet as HashSet import qualified Data.IntMap as IntMap@@ -133,6 +137,7 @@ import qualified Data.Semigroup as Semigroup import qualified Data.Sequence as Seq import qualified Data.Set as Set+import qualified Data.Strict as S import qualified Data.Text as T import qualified Data.Text.Encoding as T import qualified Data.Text.Lazy as LT@@ -148,15 +153,8 @@ import qualified Data.Primitive.Array as PM import qualified Data.Primitive.SmallArray as PM import qualified Data.Primitive.Types as PM--#if MIN_VERSION_primitive(0,6,4)-#if !MIN_VERSION_primitive(0,7,0)-import qualified Data.Primitive.UnliftedArray as PM-#endif import qualified Data.Primitive.PrimArray as PM-#endif - import Data.Coerce (Coercible, coerce)  parseIndexedJSON :: (Value -> Parser a) -> Int -> Value -> Parser a@@ -1760,8 +1758,24 @@     parseJSON = parseJSON1     {-# INLINE parseJSON #-} +#if MIN_VERSION_dlist(1,0,0) && __GLASGOW_HASKELL__ >=800+-- | @since 1.5.3.0+instance FromJSON1 DNE.DNonEmpty where+    liftParseJSON p _ = withArray "DNonEmpty" $+        (>>= ne) . Tr.sequence . zipWith (parseIndexedJSON p) [0..] . V.toList+      where+        ne []     = fail "parsing DNonEmpty failed, unexpected empty list"+        ne (x:xs) = pure (DNE.fromNonEmpty (x :| xs))+    {-# INLINE liftParseJSON #-}++-- | @since 1.5.3.0+instance (FromJSON a) => FromJSON (DNE.DNonEmpty a) where+    parseJSON = parseJSON1+    {-# INLINE parseJSON #-}+#endif+ ---------------------------------------------------------------------------------- tranformers - Functors+-- transformers - Functors -------------------------------------------------------------------------------  instance FromJSON1 Identity where@@ -2002,16 +2016,9 @@ instance FromJSON a => FromJSON (PM.SmallArray a) where   parseJSON = fmap Exts.fromList . parseJSON -#if MIN_VERSION_primitive(0,6,4) instance (PM.Prim a,FromJSON a) => FromJSON (PM.PrimArray a) where   parseJSON = fmap Exts.fromList . parseJSON -#if !MIN_VERSION_primitive(0,7,0)-instance (PM.PrimUnlifted a,FromJSON a) => FromJSON (PM.UnliftedArray a) where-  parseJSON = fmap Exts.fromList . parseJSON-#endif-#endif- ------------------------------------------------------------------------------- -- time -------------------------------------------------------------------------------@@ -2226,6 +2233,70 @@ instance FromJSON a => FromJSON (Semigroup.Option a) where     parseJSON = parseJSON1     {-# INLINE parseJSON #-}++-------------------------------------------------------------------------------+-- data-fix+-------------------------------------------------------------------------------++-- | @since 1.5.3.0+instance FromJSON1 f => FromJSON (F.Fix f) where+    parseJSON = go where go = fmap F.Fix . liftParseJSON go parseJSONList++-- | @since 1.5.3.0+instance (FromJSON1 f, Functor f) => FromJSON (F.Mu f) where+    parseJSON = fmap (F.unfoldMu F.unFix) . parseJSON++-- | @since 1.5.3.0+instance (FromJSON1 f, Functor f) => FromJSON (F.Nu f) where+    parseJSON = fmap (F.unfoldNu F.unFix) . parseJSON++-------------------------------------------------------------------------------+-- strict+-------------------------------------------------------------------------------++-- | @since 1.5.3.0+instance (FromJSON a, FromJSON b) => FromJSON (S.These a b) where+    parseJSON = fmap S.toStrict . parseJSON++-- | @since 1.5.3.0+instance FromJSON2 S.These where+    liftParseJSON2 pa pas pb pbs = fmap S.toStrict . liftParseJSON2 pa pas pb pbs++-- | @since 1.5.3.0+instance FromJSON a => FromJSON1 (S.These a) where+    liftParseJSON pa pas = fmap S.toStrict . liftParseJSON pa pas++-- | @since 1.5.3.0+instance (FromJSON a, FromJSON b) => FromJSON (S.Pair a b) where+    parseJSON = fmap S.toStrict . parseJSON++-- | @since 1.5.3.0+instance FromJSON2 S.Pair where+    liftParseJSON2 pa pas pb pbs = fmap S.toStrict . liftParseJSON2 pa pas pb pbs++-- | @since 1.5.3.0+instance FromJSON a => FromJSON1 (S.Pair a) where+    liftParseJSON pa pas = fmap S.toStrict . liftParseJSON pa pas++-- | @since 1.5.3.0+instance (FromJSON a, FromJSON b) => FromJSON (S.Either a b) where+    parseJSON = fmap S.toStrict . parseJSON++-- | @since 1.5.3.0+instance FromJSON2 S.Either where+    liftParseJSON2 pa pas pb pbs = fmap S.toStrict . liftParseJSON2 pa pas pb pbs++-- | @since 1.5.3.0+instance FromJSON a => FromJSON1 (S.Either a) where+    liftParseJSON pa pas = fmap S.toStrict . liftParseJSON pa pas++-- | @since 1.5.3.0+instance FromJSON a => FromJSON (S.Maybe a) where+    parseJSON = fmap S.toStrict . parseJSON++-- | @since 1.5.3.0+instance FromJSON1 S.Maybe where+    liftParseJSON pa pas = fmap S.toStrict . liftParseJSON pa pas  ------------------------------------------------------------------------------- -- tagged
Data/Aeson/Types/Internal.hs view
@@ -110,10 +110,6 @@ import qualified Data.Vector as V import qualified Language.Haskell.TH.Syntax as TH -#if !MIN_VERSION_unordered_containers(0,2,6)-import Data.List (sort)-#endif- -- | Elements of a JSON path used to describe the location of an -- error. data JSONPathElement = Key Text@@ -405,14 +401,7 @@     {-# INLINE fromString #-}  hashValue :: Int -> Value -> Int-#if MIN_VERSION_unordered_containers(0,2,6) hashValue s (Object o)   = s `hashWithSalt` (0::Int) `hashWithSalt` o-#else-hashValue s (Object o)   = foldl' hashWithSalt-                              (s `hashWithSalt` (0::Int)) assocHashesSorted-  where-    assocHashesSorted = sort [hash k `hashWithSalt` v | (k, v) <- H.toList o]-#endif hashValue s (Array a)    = foldl' hashWithSalt                               (s `hashWithSalt` (1::Int)) a hashValue s (String str) = s `hashWithSalt` (2::Int) `hashWithSalt` str
Data/Aeson/Types/ToJSON.hs view
@@ -103,6 +103,10 @@ import qualified Data.Aeson.Encoding.Internal as E (InArray, comma, econcat, retagEncoding) import qualified Data.ByteString.Lazy as L import qualified Data.DList as DList+#if MIN_VERSION_dlist(1,0,0) && __GLASGOW_HASKELL__ >=800+import qualified Data.DList.DNonEmpty as DNE+#endif+import qualified Data.Fix as F import qualified Data.HashMap.Strict as H import qualified Data.HashSet as HashSet import qualified Data.IntMap as IntMap@@ -114,6 +118,7 @@ import qualified Data.Semigroup as Semigroup import qualified Data.Sequence as Seq import qualified Data.Set as Set+import qualified Data.Strict as S import qualified Data.Text as T import qualified Data.Text.Encoding as T import qualified Data.Text.Lazy as LT@@ -133,13 +138,7 @@ import qualified Data.Primitive.Array as PM import qualified Data.Primitive.SmallArray as PM import qualified Data.Primitive.Types as PM--#if MIN_VERSION_primitive(0,6,4)-#if !MIN_VERSION_primitive(0,7,0)-import qualified Data.Primitive.UnliftedArray as PM-#endif import qualified Data.Primitive.PrimArray as PM-#endif  toJSONPair :: (a -> Value) -> (b -> Value) -> (a, b) -> Value toJSONPair a b = liftToJSON2 a (listValue a) b (listValue b)@@ -1618,6 +1617,24 @@     toEncoding = toEncoding1     {-# INLINE toEncoding #-} +#if MIN_VERSION_dlist(1,0,0) && __GLASGOW_HASKELL__ >=800+-- | @since 1.5.3.0+instance ToJSON1 DNE.DNonEmpty where+    liftToJSON t _ = listValue t . DNE.toList+    {-# INLINE liftToJSON #-}++    liftToEncoding t _ = listEncoding t . DNE.toList+    {-# INLINE liftToEncoding #-}++-- | @since 1.5.3.0+instance (ToJSON a) => ToJSON (DNE.DNonEmpty a) where+    toJSON = toJSON1+    {-# INLINE toJSON #-}++    toEncoding = toEncoding1+    {-# INLINE toEncoding #-}+#endif+ ------------------------------------------------------------------------------- -- transformers - Functors -------------------------------------------------------------------------------@@ -1981,18 +1998,10 @@   toJSON = toJSON . Exts.toList   toEncoding = toEncoding . Exts.toList -#if (MIN_VERSION_primitive(0,6,4)) instance (PM.Prim a,ToJSON a) => ToJSON (PM.PrimArray a) where   toJSON = toJSON . Exts.toList   toEncoding = toEncoding . Exts.toList -#if !MIN_VERSION_primitive(0,7,0)-instance (PM.PrimUnlifted a,ToJSON a) => ToJSON (PM.UnliftedArray a) where-  toJSON = toJSON . Exts.toList-  toEncoding = toEncoding . Exts.toList-#endif-#endif- ------------------------------------------------------------------------------- -- time -------------------------------------------------------------------------------@@ -2241,6 +2250,84 @@      toEncoding = toEncoding1     {-# INLINE toEncoding #-}++-------------------------------------------------------------------------------+-- data-fix+-------------------------------------------------------------------------------++-- | @since 1.5.3.0+instance ToJSON1 f => ToJSON (F.Fix f) where+    toJSON     = go where go (F.Fix f) = liftToJSON go toJSONList f+    toEncoding = go where go (F.Fix f) = liftToEncoding go toEncodingList f++-- | @since 1.5.3.0+instance (ToJSON1 f, Functor f) => ToJSON (F.Mu f) where+    toJSON     = F.foldMu (liftToJSON id (listValue id))+    toEncoding = F.foldMu (liftToEncoding id (listEncoding id))++-- | @since 1.5.3.0+instance (ToJSON1 f, Functor f) => ToJSON (F.Nu f) where+    toJSON     = F.foldNu (liftToJSON id (listValue id))+    toEncoding = F.foldNu (liftToEncoding id (listEncoding id))++-------------------------------------------------------------------------------+-- strict+-------------------------------------------------------------------------------++-- | @since 1.5.3.0+instance (ToJSON a, ToJSON b) => ToJSON (S.These a b) where+    toJSON = toJSON . S.toLazy+    toEncoding = toEncoding . S.toLazy++-- | @since 1.5.3.0+instance ToJSON2 S.These where+    liftToJSON2 toa toas tob tobs = liftToJSON2 toa toas tob tobs . S.toLazy+    liftToEncoding2 toa toas tob tobs = liftToEncoding2 toa toas tob tobs . S.toLazy++-- | @since 1.5.3.0+instance ToJSON a => ToJSON1 (S.These a) where+    liftToJSON toa tos = liftToJSON toa tos . S.toLazy+    liftToEncoding toa tos = liftToEncoding toa tos . S.toLazy++-- | @since 1.5.3.0+instance (ToJSON a, ToJSON b) => ToJSON (S.Pair a b) where+    toJSON = toJSON . S.toLazy+    toEncoding = toEncoding . S.toLazy++-- | @since 1.5.3.0+instance ToJSON2 S.Pair where+    liftToJSON2 toa toas tob tobs = liftToJSON2 toa toas tob tobs . S.toLazy+    liftToEncoding2 toa toas tob tobs = liftToEncoding2 toa toas tob tobs . S.toLazy++-- | @since 1.5.3.0+instance ToJSON a => ToJSON1 (S.Pair a) where+    liftToJSON toa tos = liftToJSON toa tos . S.toLazy+    liftToEncoding toa tos = liftToEncoding toa tos . S.toLazy++-- | @since 1.5.3.0+instance (ToJSON a, ToJSON b) => ToJSON (S.Either a b) where+    toJSON = toJSON . S.toLazy+    toEncoding = toEncoding . S.toLazy++-- | @since 1.5.3.0+instance ToJSON2 S.Either where+    liftToJSON2 toa toas tob tobs = liftToJSON2 toa toas tob tobs . S.toLazy+    liftToEncoding2 toa toas tob tobs = liftToEncoding2 toa toas tob tobs . S.toLazy++-- | @since 1.5.3.0+instance ToJSON a => ToJSON1 (S.Either a) where+    liftToJSON toa tos = liftToJSON toa tos . S.toLazy+    liftToEncoding toa tos = liftToEncoding toa tos . S.toLazy++-- | @since 1.5.3.0+instance ToJSON a => ToJSON (S.Maybe a) where+    toJSON = toJSON . S.toLazy+    toEncoding = toEncoding . S.toLazy++-- | @since 1.5.3.0+instance ToJSON1 S.Maybe where+    liftToJSON toa tos = liftToJSON toa tos . S.toLazy+    liftToEncoding toa tos = liftToEncoding toa tos . S.toLazy  ------------------------------------------------------------------------------- -- tagged
aeson.cabal view
@@ -1,5 +1,5 @@ name:            aeson-version:         1.5.2.0+version:         1.5.3.0 license:         BSD3 license-file:    LICENSE category:        Text, Web, JSON@@ -136,10 +136,12 @@   -- Other dependencies   build-depends:     attoparsec           >= 0.13.2.2 && < 0.14,-    dlist                >= 0.8.0.4  && < 0.9,+    data-fix             >= 0.3      && < 0.4,+    dlist                >= 0.8.0.4  && < 1.1,     hashable             >= 1.2.7.0  && < 1.4,     primitive            >= 0.7.0.1  && < 0.8,     scientific           >= 0.3.6.2  && < 0.4,+    strict               >= 0.4      && < 0.5,     tagged               >= 0.8.6    && < 0.9,     th-abstraction       >= 0.2.8.0  && < 0.4,     these                >= 1.1      && < 1.2,@@ -210,6 +212,7 @@     base-orphans >= 0.5.3 && <0.9,     base16-bytestring,     containers,+    data-fix,     directory,     dlist,     Diff >= 0.4 && < 0.5,@@ -218,6 +221,7 @@     ghc-prim >= 0.2,     hashable >= 1.2.4.0,     scientific,+    strict,     tagged,     template-haskell,     tasty,@@ -231,7 +235,7 @@     unordered-containers,     uuid-types,     vector,-    quickcheck-instances >= 0.3.23 && <0.4+    quickcheck-instances >= 0.3.24 && <0.4    if flag(bytestring-builder)     build-depends: bytestring >= 0.9 && < 0.10.4,
benchmarks/aeson-benchmarks.cabal view
@@ -9,6 +9,7 @@   c-sources:        ../cbits/unescape_string.c   build-depends:       attoparsec+    , data-fix     , base     , base-compat-batteries     , bytestring             >=0.10.4@@ -21,6 +22,7 @@     , primitive     , scientific     , syb+    , strict     , tagged     , template-haskell     , text
changelog.md view
@@ -1,5 +1,11 @@ For the latest version of this document, please see [https://github.com/bos/aeson/blob/master/changelog.md](https://github.com/bos/aeson/blob/master/changelog.md). +### 1.5.3.0++* Add instances for types in `strict` and `data-fix` packages, thanks to Oleg Grenrus.+* CPP cleanup, thanks to Oleg Grenrus.+* Instances for `dlist`'s `Data.DList.DNonEmpty.DNonEmpty`, thanks to Oleg Grenrus.+ ### 1.5.2.0  * Add `Ord Value` instance, thanks to Oleg Grenrus.
tests/PropertyRoundTrip.hs view
@@ -26,6 +26,8 @@ import qualified Data.Text as T import qualified Data.Text.Lazy as LT import qualified Data.UUID.Types as UUID+import qualified Data.Strict as S+import qualified Data.Fix as F import PropUtils import PropertyRTFunctors @@ -66,6 +68,13 @@     , testProperty "Ratio Int" $ roundTripEq (undefined :: Ratio Int)     , testProperty "UUID" $ roundTripEq UUID.nil     , testProperty "These" $ roundTripEq (These 'x' True)+    , testProperty "Fix" $ roundTripEq (undefined :: F.Fix (These Char))+    , testProperty "Mu" $ roundTripEq (undefined :: F.Mu (These Char))+    , testProperty "Nu" $ roundTripEq (undefined :: F.Nu (These Char))+    , testProperty "Strict Pair" $ roundTripEq (undefined :: S.Pair Int Char)+    , testProperty "Strict Either" $ roundTripEq (undefined :: S.Either Int Char)+    , testProperty "Strict These" $ roundTripEq (undefined :: S.These Int Char)+    , testProperty "Strict Maybe" $ roundTripEq (undefined :: S.Maybe Int)     , roundTripFunctorsTests     , testGroup "ghcGenerics" [         testProperty "OneConstructor" $ roundTripEq OneConstructor
tests/SerializationFormatSpec.hs view
@@ -54,6 +54,8 @@ import qualified Data.Tree as Tree import qualified Data.UUID.Types as UUID import qualified Data.Vector as Vector+import qualified Data.Fix as F+import qualified Data.Strict as S  tests :: [TestTree] tests =@@ -218,6 +220,26 @@     , "{\"That\":false,\"This\":\"y\"}"     ]     (These 'y' False)++  -- data-fix and strict+  , ndExample "Fix Strict.These"+    [ "{\"This\":true,\"That\":{\"That\":{\"This\":false}}}"+    , "{\"That\":{\"That\":{\"This\":false}},\"This\":true}"+    ]+    (F.Fix (S.These True (F.Fix (S.That (F.Fix (S.This False))))))++  -- Mu and Nu are similar.+  , ndExample "Mu Strict.These"+    [ "{\"This\":true,\"That\":{\"That\":{\"This\":false}}}"+    , "{\"That\":{\"That\":{\"This\":false}},\"This\":true}"+    ]+    $ F.unfoldMu F.unFix $ F.Fix (S.These True (F.Fix (S.That (F.Fix (S.This False)))))++  , ndExample "Nu Strict.These"+    [ "{\"This\":true,\"That\":{\"That\":{\"This\":false}}}"+    , "{\"That\":{\"That\":{\"This\":false}},\"This\":true}"+    ]+    $ F.unfoldNu F.unFix $ F.Fix (S.These True (F.Fix (S.That (F.Fix (S.This False)))))   ]  jsonEncodingExamples :: [Example]