Hello community, here is the log from the commit of package ghc-aeson-extra for openSUSE:Factory checked in at 2015-12-23 08:49:06 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-aeson-extra (Old) and /work/SRC/openSUSE:Factory/.ghc-aeson-extra.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-aeson-extra" Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-aeson-extra/ghc-aeson-extra.changes 2015-11-26 17:02:21.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.ghc-aeson-extra.new/ghc-aeson-extra.changes 2015-12-23 08:49:07.000000000 +0100 @@ -1,0 +2,7 @@ +Sun Dec 13 13:40:27 UTC 2015 - [email protected] + +- update to 0.2.3.0 +* Data.Time.TH module with mkUTCTime +* encodeStrict in Data.Aeson.Extra + +------------------------------------------------------------------- Old: ---- aeson-extra-0.2.2.0.tar.gz New: ---- aeson-extra-0.2.3.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-aeson-extra.spec ++++++ --- /var/tmp/diff_new_pack.8HJ0p4/_old 2015-12-23 08:49:08.000000000 +0100 +++ /var/tmp/diff_new_pack.8HJ0p4/_new 2015-12-23 08:49:08.000000000 +0100 @@ -15,17 +15,18 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # + %global pkg_name aeson-extra %bcond_with tests Name: ghc-aeson-extra -Version: 0.2.2.0 +Version: 0.2.3.0 Release: 0 Summary: Extra goodies for aeson +License: BSD-3-Clause Group: System/Libraries -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 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -75,37 +76,29 @@ %prep %setup -q -n %{pkg_name}-%{version} - %build %ghc_lib_build - %install %ghc_lib_install - %check %if %{with tests} %cabal test %endif - %post devel %ghc_pkg_recache - %postun devel %ghc_pkg_recache - %files -f %{name}.files %defattr(-,root,root,-) %doc LICENSE - %files devel -f %{name}-devel.files %defattr(-,root,root,-) %doc README.md - %changelog ++++++ aeson-extra-0.2.2.0.tar.gz -> aeson-extra-0.2.3.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aeson-extra-0.2.2.0/CHANGELOG.md new/aeson-extra-0.2.3.0/CHANGELOG.md --- old/aeson-extra-0.2.2.0/CHANGELOG.md 2015-11-10 14:20:38.000000000 +0100 +++ new/aeson-extra-0.2.3.0/CHANGELOG.md 2015-12-08 12:19:10.000000000 +0100 @@ -1,3 +1,8 @@ +# 0.2.3.0 (2015-12-08) + +- `Data.Time.TH` module with `mkUTCTime` +- `encodeStrict` in `Data.Aeson.Extra` + # 0.2.2.0 (2015-11-10) - `U` and `Z` to parse `UTCTime` and `ZonedTime` compatibly diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aeson-extra-0.2.2.0/aeson-extra.cabal new/aeson-extra-0.2.3.0/aeson-extra.cabal --- old/aeson-extra-0.2.2.0/aeson-extra.cabal 2015-11-10 14:21:15.000000000 +0100 +++ new/aeson-extra-0.2.3.0/aeson-extra.cabal 2015-12-08 12:19:23.000000000 +0100 @@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: aeson-extra -version: 0.2.2.0 +version: 0.2.3.0 synopsis: Extra goodies for aeson description: The package motivation is twofold: . @@ -42,6 +42,7 @@ , exceptions >=0.8 && <0.9 , hashable >=1.2 && <1.3 , scientific >=0.3 && <0.4 + , template-haskell >=2.8 && <2.11 , text >=1.2 && <1.3 , time >=1.4.2 && <1.6 , unordered-containers >=0.2 && <0.3 @@ -49,6 +50,7 @@ exposed-modules: Data.Aeson.Compat Data.Aeson.Extra + Data.Time.TH other-modules: Data.Aeson.Extra.Time default-language: Haskell2010 @@ -68,6 +70,7 @@ , exceptions >=0.8 && <0.9 , hashable >=1.2 && <1.3 , scientific >=0.3 && <0.4 + , template-haskell >=2.8 && <2.11 , text >=1.2 && <1.3 , time >=1.4.2 && <1.6 , unordered-containers >=0.2 && <0.3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aeson-extra-0.2.2.0/src/Data/Aeson/Extra.hs new/aeson-extra-0.2.3.0/src/Data/Aeson/Extra.hs --- old/aeson-extra-0.2.2.0/src/Data/Aeson/Extra.hs 2015-11-10 14:20:38.000000000 +0100 +++ new/aeson-extra-0.2.3.0/src/Data/Aeson/Extra.hs 2015-12-08 12:18:32.000000000 +0100 @@ -18,6 +18,8 @@ -- -- More or less useful newtypes for writing 'FromJSON' & 'ToJSON' instances module Data.Aeson.Extra ( + -- * Strict encoding + encodeStrict, -- * Generic maps M(..), FromJSONKey(..), @@ -51,6 +53,8 @@ import Control.Applicative import Data.Monoid +import qualified Data.ByteString as BS +import qualified Data.ByteString.Lazy as LBS import Data.Aeson.Compat import Data.Aeson.Types hiding ((.:?)) import qualified Data.Foldable as Foldable @@ -71,6 +75,10 @@ import qualified Data.Aeson.Extra.Time as ExtraTime #endif +-- | Like 'encode', but produces strict 'BS.ByteString'. +encodeStrict :: ToJSON a => a -> BS.ByteString +encodeStrict = LBS.toStrict . encode + -- | A wrapper type to parse arbitrary maps -- -- > λ > decode "{\"1\": 1, \"2\": 2}" :: Maybe (M (H.HashMap Int Int)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aeson-extra-0.2.2.0/src/Data/Time/TH.hs new/aeson-extra-0.2.3.0/src/Data/Time/TH.hs --- old/aeson-extra-0.2.2.0/src/Data/Time/TH.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/aeson-extra-0.2.3.0/src/Data/Time/TH.hs 2015-12-08 12:18:32.000000000 +0100 @@ -0,0 +1,25 @@ +{-# LANGUAGE TemplateHaskell #-} +-- | Template Haskell extras for `Data.Time`. +-- +-- This module is in a wrong place, but it reuses the same parser as aeson parser. +module Data.Time.TH (mkUTCTime) where + +import Control.Applicative ((<*)) +import Data.Time (UTCTime(..), Day(..)) +import qualified Data.Text as T +import qualified Data.Attoparsec.Text as A +import Language.Haskell.TH +import Data.Aeson.Extra.Time (utcTime) + +-- | Make a 'UTCTime'. Accepts the same strings as aeson `UTCTime` parser accepts. +-- +-- > t :: UTCTime +-- > t = $(mkUTCTime "2014-05-12 00:02:03.456000Z") +mkUTCTime :: String -> Q Exp +mkUTCTime s = + case A.parseOnly (utcTime <* A.endOfInput) (T.pack s) of + Left err -> fail $ "could not parse UTCTime: " ++ err + Right (UTCTime (ModifiedJulianDay d) dt) -> + [| UTCTime (ModifiedJulianDay $(d')) $(dt') :: UTCTime |] + where d' = return $ LitE $ integerL d + dt' = return $ LitE $ rationalL $ toRational dt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aeson-extra-0.2.2.0/test/Tests.hs new/aeson-extra-0.2.3.0/test/Tests.hs --- old/aeson-extra-0.2.2.0/test/Tests.hs 2015-11-10 14:20:38.000000000 +0100 +++ new/aeson-extra-0.2.3.0/test/Tests.hs 2015-12-08 12:18:32.000000000 +0100 @@ -2,18 +2,18 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE KindSignatures #-} +{-# LANGUAGE TemplateHaskell #-} module Main (main) where #if !MIN_VERSION_base(4,8,0) import Control.Applicative #endif -import Data.Aeson.Extra import qualified Data.HashMap.Lazy as H import Data.Map (Map) import Data.Maybe (isJust) import Data.String (fromString) -import Data.Time (zonedTimeToUTC) +import Data.Time (zonedTimeToUTC, UTCTime(..), Day(..)) import Data.Vector (Vector) import Test.QuickCheck.Instances () import Test.Tasty @@ -24,11 +24,15 @@ import Data.Proxy #endif +import Data.Aeson.Extra +import Data.Time.TH + import Orphans () main :: IO () main = defaultMain $ testGroup "Tests" [ dotColonMark + , encodeStrictTests , mTests #if MIN_VERSION_base(4,7,0) , symTests @@ -37,7 +41,20 @@ , collapsedListTests , utctimeTests , zonedtimeTests + , timeTHTests + ] + +------------------------------------------------------------------------------ +-- encodeStrict +------------------------------------------------------------------------------ +encodeStrictTests :: TestTree +encodeStrictTests = testGroup "encodeStrict" + [ testProperty "decodeStrict . encodeStrict" prop ] + where prop :: Int -> Property + prop i = let lhs = decodeStrict . encodeStrict $ i + rhs = Just i + in lhs === rhs ------------------------------------------------------------------------------ -- M @@ -190,3 +207,15 @@ , "2015-09-07 11:16:40.807 +03:00" , "2015-09-07 05:16:40.807 -03:00" ] + +------------------------------------------------------------------------------ +-- Time Template Haskell +------------------------------------------------------------------------------ + +timeTHTests :: TestTree +timeTHTests = + testCase "time TH example" $ assertBool "should be equal" $ lhs == rhs + where lhs = UTCTime (ModifiedJulianDay 56789) 123.456 + rhs = $(mkUTCTime "2014-05-12 00:02:03.456000Z") + + \ No newline at end of file
