Hello community,
here is the log from the commit of package ghc-aeson-compat for openSUSE:Factory checked in at 2016-02-17 10:25:42
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-aeson-compat (Old)
and /work/SRC/openSUSE:Factory/.ghc-aeson-compat.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-aeson-compat"
Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-aeson-compat/ghc-aeson-compat.changes 2015-12-29 12:59:46.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.ghc-aeson-compat.new/ghc-aeson-compat.changes 2016-02-17 12:11:35.000000000 +0100
@@ -1,0 +2,9 @@
+Wed Feb 10 11:01:44 UTC 2016 - mimi.vx@gmail.com
+
+- update to 0.3.1.0
+- add remove_nats.patch
+* aeson-0.11 support
+* Add ToJSON Day and LocalTime instances
+* Add Natural, Ordering and Version instances
+
+-------------------------------------------------------------------
Old:
----
aeson-compat-0.3.0.0.tar.gz
New:
----
aeson-compat-0.3.1.0.tar.gz
remove_nats.patch
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ghc-aeson-compat.spec ++++++
--- /var/tmp/diff_new_pack.UtTnVi/_old 2016-02-17 12:11:36.000000000 +0100
+++ /var/tmp/diff_new_pack.UtTnVi/_new 2016-02-17 12:11:36.000000000 +0100
@@ -20,7 +20,7 @@
%bcond_with tests
Name: ghc-aeson-compat
-Version: 0.3.0.0
+Version: 0.3.1.0
Release: 0
Summary: Compatibility layer for aeson
Group: System/Libraries
@@ -28,6 +28,8 @@
License: BSD-3-Clause
Url: https://hackage.haskell.org/package/%{pkg_name}
Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
+# PATCH-FIX-OPENSUSE remove_nats.patch -- mimi.vx@gmail.com
+Patch0: remove_nats.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: ghc-Cabal-devel
@@ -42,6 +44,7 @@
BuildRequires: ghc-scientific-devel
BuildRequires: ghc-text-devel
BuildRequires: ghc-time-devel
+BuildRequires: ghc-time-locale-compat-devel
BuildRequires: ghc-unordered-containers-devel
BuildRequires: ghc-vector-devel
%if %{with tests}
@@ -70,7 +73,7 @@
%prep
%setup -q -n %{pkg_name}-%{version}
-
+%patch0 -p1
%build
%ghc_lib_build
++++++ aeson-compat-0.3.0.0.tar.gz -> aeson-compat-0.3.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aeson-compat-0.3.0.0/CHANGELOG.md new/aeson-compat-0.3.1.0/CHANGELOG.md
--- old/aeson-compat-0.3.0.0/CHANGELOG.md 2015-12-25 16:40:06.000000000 +0100
+++ new/aeson-compat-0.3.1.0/CHANGELOG.md 2016-02-09 14:03:41.000000000 +0100
@@ -1,3 +1,11 @@
+# 0.3.1.0
+
+- `aeson-0.11` support
+- GHC 8.0.1 support
+- Add `ToJSON` `Day` and `LocalTime` instances
+ - *NOTE* this instances are broken in `aeson-0.10.0.0`
+- Add `Natural`, `Ordering` and `Version` instances
+
# 0.3.0.0
-Split out `aeson-extra`
\ No newline at end of file
+Split out `aeson-extra`
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aeson-compat-0.3.0.0/aeson-compat.cabal new/aeson-compat-0.3.1.0/aeson-compat.cabal
--- old/aeson-compat-0.3.0.0/aeson-compat.cabal 2015-12-25 16:57:50.000000000 +0100
+++ new/aeson-compat-0.3.1.0/aeson-compat.cabal 2016-02-09 14:03:41.000000000 +0100
@@ -3,7 +3,7 @@
-- see: https://github.com/sol/hpack
name: aeson-compat
-version: 0.3.0.0
+version: 0.3.1.0
synopsis: Compatibility layer for aeson
description: Compatibility layer for @aeson@
category: Web
@@ -13,7 +13,7 @@
maintainer: Oleg Grenrus
license: BSD3
license-file: LICENSE
-tested-with: GHC==7.6.3, GHC==7.8.4, GHC==7.10.3
+tested-with: GHC==7.6.3, GHC==7.8.4, GHC==7.10.3, GHC==8.0.1
build-type: Simple
cabal-version: >= 1.10
@@ -30,16 +30,18 @@
src
ghc-options: -Wall
build-depends:
- base >=4.6 && <4.9
- , aeson >=0.7.0.6 && <0.11
+ base >=4.6 && <4.10
+ , aeson >=0.7.0.6 && <0.11.1
, attoparsec >=0.12 && <0.14
, bytestring >=0.10 && <0.11
, containers >=0.5 && <0.6
, exceptions >=0.8 && <0.9
, hashable >=1.2 && <1.3
+ , nats >=1 && <1.2
, scientific >=0.3 && <0.4
, text >=1.2 && <1.3
, time >=1.4.2 && <1.7
+ , time-locale-compat >=0.1.0.1 && <0.2
, unordered-containers >=0.2 && <0.3
, vector >=0.10 && <0.12
exposed-modules:
@@ -55,23 +57,26 @@
test
ghc-options: -Wall
build-depends:
- base >=4.6 && <4.9
- , aeson >=0.7.0.6 && <0.11
+ base >=4.6 && <4.10
+ , aeson >=0.7.0.6 && <0.11.1
, attoparsec >=0.12 && <0.14
, bytestring >=0.10 && <0.11
, containers >=0.5 && <0.6
, exceptions >=0.8 && <0.9
, hashable >=1.2 && <1.3
+ , nats >=1 && <1.2
, scientific >=0.3 && <0.4
, text >=1.2 && <1.3
, time >=1.4.2 && <1.7
+ , time-locale-compat >=0.1.0.1 && <0.2
, unordered-containers >=0.2 && <0.3
, vector >=0.10 && <0.12
, aeson-compat
, tasty >=0.10 && <0.12
, tasty-hunit >=0.9 && <0.10
, tasty-quickcheck >=0.8 && <0.9
- , quickcheck-instances >=0.3 && <0.4
+ , QuickCheck >=2.7.6 && <2.8.3
+ , quickcheck-instances >=0.3 && <0.3.13
other-modules:
Orphans
default-language: Haskell2010
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aeson-compat-0.3.0.0/src/Data/Aeson/Compat/Time.hs new/aeson-compat-0.3.1.0/src/Data/Aeson/Compat/Time.hs
--- old/aeson-compat-0.3.0.0/src/Data/Aeson/Compat/Time.hs 2015-12-25 16:41:24.000000000 +0100
+++ new/aeson-compat-0.3.1.0/src/Data/Aeson/Compat/Time.hs 2016-02-09 14:03:41.000000000 +0100
@@ -3,7 +3,7 @@
-- |
-- Module: Data.Aeson.Compat.Time (Data.Aeson.Parser.Time)
-- Copyright: (c) 2015 Bryan O'Sullivan
--- License: Apache
+-- License: BSD3
-- Maintainer: Bryan O'Sullivan
-- Stability: experimental
-- Portability: portable
@@ -39,7 +39,7 @@
import Control.Applicative ((<$>), (<*>), (<*), (*>))
#endif
--- from Data.Aeson.Internal.Time
+--- from Data.Aeson.Internal.Time
import Unsafe.Coerce (unsafeCoerce)
toPico :: Integer -> Pico
@@ -67,12 +67,12 @@
let c2d c = ord c .&. 15
return $! c2d a * 10 + c2d b
--- | Parse a time of the form @HH:MM:SS[.SSS]@.
+-- | Parse a time of the form @HH:MM[:SS[.SSS]]@.
timeOfDay :: Parser Local.TimeOfDay
timeOfDay = do
- h <- twoDigits <* char ':'
- m <- twoDigits <* char ':'
- s <- seconds
+ h <- twoDigits
+ m <- char ':' *> twoDigits
+ s <- option 0 (char ':' *> seconds)
if h < 24 && m < 60 && s < 61
then return (Local.TimeOfDay h m s)
else fail "invalid time"
@@ -125,9 +125,9 @@
let !tz = Local.minutesToTimeZone off
in return (Just tz)
--- | Parse a date and time, of the form @YYYY-MM-DD HH:MM:SS@.
--- The space may be replaced with a @T@. The number of seconds may be
--- followed by a fractional component.
+-- | Parse a date and time, of the form @YYYY-MM-DD HH:MM[:SS[.SSS]]@.
+-- The space may be replaced with a @T@. The number of seconds is optional
+-- and may be followed by a fractional component.
localTime :: Parser Local.LocalTime
localTime = Local.LocalTime <$> day <* daySep <*> timeOfDay
where daySep = satisfy (\c -> c == 'T' || c == ' ')
@@ -145,7 +145,9 @@
-- | Parse a date with time zone info. Acceptable formats:
--
+-- @YYYY-MM-DD HH:MM Z@
-- @YYYY-MM-DD HH:MM:SS Z@
+-- @YYYY-MM-DD HH:MM:SS.SSS Z@
--
-- The first space may instead be a @T@, and the second space is
-- optional. The @Z@ represents UTC. The @Z@ may be replaced with a
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aeson-compat-0.3.0.0/src/Data/Aeson/Compat.hs new/aeson-compat-0.3.1.0/src/Data/Aeson/Compat.hs
--- old/aeson-compat-0.3.0.0/src/Data/Aeson/Compat.hs 2015-12-25 17:05:51.000000000 +0100
+++ new/aeson-compat-0.3.1.0/src/Data/Aeson/Compat.hs 2016-02-09 14:03:41.000000000 +0100
@@ -1,5 +1,6 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
-----------------------------------------------------------------------------
-- |
@@ -57,16 +58,27 @@
import Control.Monad.Catch
import Data.Aeson.Types hiding ((.:?))
import Data.ByteString as B
+import qualified Data.Scientific as Scientific
import Data.ByteString.Lazy as L
import qualified Data.HashMap.Strict as H
import Data.Text as T
import Data.Typeable (Typeable)
#if !MIN_VERSION_aeson(0,10,0)
-import Data.Time (Day, LocalTime)
+import Data.Time (Day, LocalTime, formatTime)
+import Data.Time.Locale.Compat (defaultTimeLocale)
import qualified Data.Aeson.Compat.Time as CompatTime
#endif
+#if !(MIN_VERSION_aeson(0,11,0) && MIN_VERSION_base(4,8,0))
+import Numeric.Natural (Natural)
+#endif
+
+#if !MIN_VERSION_aeson(0,11,0)
+import Data.Version (Version, showVersion, parseVersion)
+import Text.ParserCombinators.ReadP (readP_to_S)
+#endif
+
-- | Exception thrown by 'decode' - family of functions in this module.
newtype AesonException = AesonException String
deriving (Show, Typeable)
@@ -117,6 +129,7 @@
#endif
{-# INLINE (.:?) #-}
+#if !MIN_VERSION_aeson(0,11,0)
-- | Like '.:?', but the resulting parser will fail,
-- if the key is present but is 'Null'.
(.:!) :: (FromJSON a) => Object -> Text -> Parser (Maybe a)
@@ -131,6 +144,7 @@
Just <$> parseJSON v
#endif
{-# INLINE (.:!) #-}
+#endif
#if !MIN_VERSION_aeson(0,9,0)
-- From Parser.Internal
@@ -185,10 +199,80 @@
#endif
+-----------------------------------------------------------------------
+-- Instances in aeson-0.10
+-----------------------------------------------------------------------
+
#if !MIN_VERSION_aeson(0,10,0)
instance FromJSON Day where
parseJSON = withText "Day" (CompatTime.run CompatTime.day)
instance FromJSON LocalTime where
parseJSON = withText "LocalTime" (CompatTime.run CompatTime.localTime)
+
+instance ToJSON Day where
+ toJSON = toJSON . T.pack . formatTime defaultTimeLocale "%F"
+
+instance ToJSON LocalTime where
+ toJSON = toJSON . T.pack . formatTime defaultTimeLocale "%FT%T%Q"
+#endif
+
+-----------------------------------------------------------------------
+-- Instances in aeson-0.11
+-----------------------------------------------------------------------
+
+#if !(MIN_VERSION_aeson(0,11,0) && MIN_VERSION_base(4,8,0))
+instance ToJSON Natural where
+ toJSON = toJSON . toInteger
+ {-# INLINE toJSON #-}
+
+#if MIN_VERSION_aeson(0,10,0)
+ toEncoding = toEncoding . toInteger
+ {-# INLINE toEncoding #-}
+#endif
+
+instance FromJSON Natural where
+ parseJSON = withScientific "Natural" $ \s ->
+ if Scientific.coefficient s < 0
+ then fail $ "Expected a Natural number but got the negative number: " ++ show s
+ else pure $ truncate s
+#endif
+
+#if !MIN_VERSION_aeson(0,11,0)
+instance ToJSON Version where
+ toJSON = toJSON . showVersion
+ {-# INLINE toJSON #-}
+
+#if MIN_VERSION_aeson(0,10,0)
+ toEncoding = toEncoding . showVersion
+ {-# INLINE toEncoding #-}
+#endif
+
+instance FromJSON Version where
+ {-# INLINE parseJSON #-}
+ parseJSON = withText "Version" $ go . readP_to_S parseVersion . T.unpack
+ where
+ go [(v,[])] = return v
+ go (_ : xs) = go xs
+ go _ = fail $ "could not parse Version"
+
+instance ToJSON Ordering where
+ toJSON = toJSON . orderingToText
+#if MIN_VERSION_aeson(0,10,0)
+ toEncoding = toEncoding . orderingToText
+#endif
+
+orderingToText :: Ordering -> T.Text
+orderingToText o = case o of
+ LT -> "LT"
+ EQ -> "EQ"
+ GT -> "GT"
+
+instance FromJSON Ordering where
+ parseJSON = withText "Ordering" $ \s ->
+ case s of
+ "LT" -> return LT
+ "EQ" -> return EQ
+ "GT" -> return GT
+ _ -> fail "Parsing Ordering value failed: expected \"LT\", \"EQ\", or \"GT\""
#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aeson-compat-0.3.0.0/test/Orphans.hs new/aeson-compat-0.3.1.0/test/Orphans.hs
--- old/aeson-compat-0.3.0.0/test/Orphans.hs 2015-12-25 16:37:57.000000000 +0100
+++ new/aeson-compat-0.3.1.0/test/Orphans.hs 2016-02-09 14:03:41.000000000 +0100
@@ -7,8 +7,24 @@
#endif
import Data.Vector as V
+import Data.Version (Version(..))
import Test.Tasty.QuickCheck
+#if !(MIN_VERSION_QuickCheck(2,8,0) && MIN_VERSION_base(4,8,0))
+import Numeric.Natural (Natural)
+#endif
+
instance Arbitrary a => Arbitrary (Vector a) where
arbitrary = V.fromList <$> arbitrary
shrink = fmap V.fromList . shrink . V.toList
+
+#if !(MIN_VERSION_QuickCheck(2,8,0) && MIN_VERSION_base(4,8,0))
+instance Arbitrary Natural where
+ arbitrary = fmap (fromInteger . abs) arbitrary
+#endif
+
+instance Arbitrary Version where
+ arbitrary = do
+ x <- fmap abs arbitrary
+ xs <- (fmap . fmap) abs arbitrary
+ return $ Version (x : xs) []
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aeson-compat-0.3.0.0/test/Tests.hs new/aeson-compat-0.3.1.0/test/Tests.hs
--- old/aeson-compat-0.3.0.0/test/Tests.hs 2015-12-25 16:47:02.000000000 +0100
+++ new/aeson-compat-0.3.1.0/test/Tests.hs 2016-02-09 14:03:41.000000000 +0100
@@ -2,12 +2,13 @@
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where
-#if !MIN_VERSION_base(4,8,0)
-import Control.Applicative
-#endif
+import Data.Time (Day, LocalTime)
+import Data.Version (Version)
+import Numeric.Natural (Natural)
import Test.QuickCheck.Instances ()
import Test.Tasty
+import Test.Tasty.QuickCheck
import Test.Tasty.HUnit
import Data.Aeson.Compat
@@ -17,6 +18,13 @@
main :: IO ()
main = defaultMain $ testGroup "Tests"
[ dotColonMark
+ , testGroup "Roundtrip"
+ [ testProperty "Day" $ roundtripBroken10 (undefined :: Day)
+ , testProperty "LocalTime" $ roundtripBroken10 (undefined :: LocalTime)
+ , testProperty "Version" $ roundtrip (undefined :: Version)
+ , testProperty "Ordering" $ roundtrip (undefined :: Ordering)
+ , testProperty "Natural" $ roundtrip (undefined :: Natural)
+ ]
]
------------------------------------------------------------------------------
@@ -49,4 +57,15 @@
ex2 = "{\"value\": 42 }"
ex3 = "{\"value\": null }"
t = testCase "-"
-
\ No newline at end of file
+
+roundtrip :: (Arbitrary a, Eq a, Show a, ToJSON a, FromJSON a) => a -> a -> Property
+roundtrip _ x = Right x === (eitherDecode . encode $ x)
+
+roundtripBroken10 :: (Arbitrary a, Eq a, Show a, ToJSON a, FromJSON a) => a -> a -> Property
+#if MIN_VERSION_aeson(0,10,0) && !MIN_VERSION_aeson(0,11,0)
+roundtripBroken10 _ x = property $ case eitherDecode . encode $ x of
+ Right y -> False && x == y -- x and y of the same type!
+ Left _ -> True
+#else
+roundtripBroken10 = roundtrip
+#endif
++++++ remove_nats.patch ++++++
Index: aeson-compat-0.3.1.0/aeson-compat.cabal
===================================================================
--- aeson-compat-0.3.1.0.orig/aeson-compat.cabal
+++ aeson-compat-0.3.1.0/aeson-compat.cabal
@@ -37,7 +37,6 @@ library
, containers >=0.5 && <0.6
, exceptions >=0.8 && <0.9
, hashable >=1.2 && <1.3
- , nats >=1 && <1.2
, scientific >=0.3 && <0.4
, text >=1.2 && <1.3
, time >=1.4.2 && <1.7
@@ -64,7 +63,6 @@ test-suite aeson-compat-test
, containers >=0.5 && <0.6
, exceptions >=0.8 && <0.9
, hashable >=1.2 && <1.3
- , nats >=1 && <1.2
, scientific >=0.3 && <0.4
, text >=1.2 && <1.3
, time >=1.4.2 && <1.7