Hello community,

here is the log from the commit of package ghc-path for openSUSE:Factory 
checked in at 2016-06-25 02:21:04
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-path (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-path.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-path"

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-path/ghc-path.changes        2016-03-16 
10:33:38.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.ghc-path.new/ghc-path.changes   2016-06-25 
02:21:55.000000000 +0200
@@ -1,0 +2,6 @@
+Fri Jun 17 06:28:34 UTC 2016 - [email protected]
+
+- update to 0.5.8
+* Add Aeson instances.
+
+-------------------------------------------------------------------

Old:
----
  path-0.5.7.tar.gz

New:
----
  path-0.5.8.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-path.spec ++++++
--- /var/tmp/diff_new_pack.XcKx2O/_old  2016-06-25 02:21:56.000000000 +0200
+++ /var/tmp/diff_new_pack.XcKx2O/_new  2016-06-25 02:21:56.000000000 +0200
@@ -21,7 +21,7 @@
 %bcond_with tests
 
 Name:           ghc-path
-Version:        0.5.7
+Version:        0.5.8
 Release:        0
 Summary:        Path
 License:        BSD-3-Clause
@@ -34,6 +34,7 @@
 BuildRequires:  ghc-Cabal-devel
 BuildRequires:  ghc-rpm-macros
 # Begin cabal-rpm deps:
+BuildRequires:  ghc-aeson-devel
 BuildRequires:  ghc-deepseq-devel
 BuildRequires:  ghc-exceptions-devel
 BuildRequires:  ghc-filepath-devel

++++++ path-0.5.7.tar.gz -> path-0.5.8.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/path-0.5.7/CHANGELOG new/path-0.5.8/CHANGELOG
--- old/path-0.5.7/CHANGELOG    2016-03-06 17:43:45.000000000 +0100
+++ new/path-0.5.8/CHANGELOG    2016-06-16 14:24:12.000000000 +0200
@@ -1,3 +1,6 @@
+0.5.8
+       * Add Aeson instances.
+
 0.5.7:
        * Fix haddock problem.
 0.5.6:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/path-0.5.7/path.cabal new/path-0.5.8/path.cabal
--- old/path-0.5.7/path.cabal   2016-03-06 17:43:32.000000000 +0100
+++ new/path-0.5.8/path.cabal   2016-06-16 14:23:48.000000000 +0200
@@ -1,5 +1,5 @@
 name:                path
-version:             0.5.7
+version:             0.5.8
 synopsis:            Support for well-typed paths
 description:         Support for will-typed paths.
 license:             BSD3
@@ -21,12 +21,14 @@
                    , filepath
                    , template-haskell
                    , deepseq
+                   , aeson
 
 test-suite test
     type: exitcode-stdio-1.0
     main-is: Main.hs
     hs-source-dirs: test
     build-depends: HUnit
+                 , aeson
                  , base
                  , hspec
                  , mtl
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/path-0.5.7/src/Path/Internal.hs 
new/path-0.5.8/src/Path/Internal.hs
--- old/path-0.5.7/src/Path/Internal.hs 2016-03-04 14:32:28.000000000 +0100
+++ new/path-0.5.8/src/Path/Internal.hs 2016-06-16 11:39:06.000000000 +0200
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE DeriveDataTypeable #-}
 
 -- | Internal types and functions.
@@ -7,6 +8,7 @@
   where
 
 import Control.DeepSeq (NFData (..))
+import Data.Aeson (ToJSON (..))
 import Data.Data
 
 -- | Path of some base and type.
@@ -47,3 +49,11 @@
 
 instance NFData (Path b t) where
   rnf (Path x) = rnf x
+
+instance ToJSON (Path b t) where
+  toJSON (Path x) = toJSON x
+  {-# INLINE toJSON #-}
+#if MIN_VERSION_aeson(0,10,0)
+  toEncoding (Path x) = toEncoding x
+  {-# INLINE toEncoding #-}
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/path-0.5.7/src/Path.hs new/path-0.5.8/src/Path.hs
--- old/path-0.5.7/src/Path.hs  2016-03-06 17:43:28.000000000 +0100
+++ new/path-0.5.8/src/Path.hs  2016-06-16 11:39:06.000000000 +0200
@@ -12,6 +12,7 @@
 {-# LANGUAGE TemplateHaskell #-}
 {-# LANGUAGE DeriveDataTypeable #-}
 {-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE FlexibleInstances #-}
 
 module Path
   (-- * Types
@@ -49,6 +50,8 @@
 
 import           Control.Exception (Exception)
 import           Control.Monad.Catch (MonadThrow(..))
+import           Data.Aeson (FromJSON (..))
+import qualified Data.Aeson.Types as Aeson
 import           Data.Data
 import           Data.List
 import           Data.Maybe
@@ -71,6 +74,31 @@
 -- | A directory path.
 data Dir deriving (Typeable)
 
+instance FromJSON (Path Abs File) where
+  parseJSON = parseJSONWith parseAbsFile
+  {-# INLINE parseJSON #-}
+
+instance FromJSON (Path Rel File) where
+  parseJSON = parseJSONWith parseRelFile
+  {-# INLINE parseJSON #-}
+
+instance FromJSON (Path Abs Dir) where
+  parseJSON = parseJSONWith parseAbsDir
+  {-# INLINE parseJSON #-}
+
+instance FromJSON (Path Rel Dir) where
+  parseJSON = parseJSONWith parseRelDir
+  {-# INLINE parseJSON #-}
+
+parseJSONWith :: (Show e, FromJSON a)
+              => (a -> Either e b) -> Aeson.Value -> Aeson.Parser b
+parseJSONWith f x =
+  do fp <- parseJSON x
+     case f fp of
+       Right p -> return p
+       Left e -> fail (show e)
+{-# INLINE parseJSONWith #-}
+
 -- | Exception when parsing a location.
 data PathParseException
   = InvalidAbsDir FilePath
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/path-0.5.7/test/Main.hs new/path-0.5.8/test/Main.hs
--- old/path-0.5.7/test/Main.hs 2016-03-04 15:09:08.000000000 +0100
+++ new/path-0.5.8/test/Main.hs 2016-06-16 14:23:42.000000000 +0200
@@ -1,4 +1,5 @@
 {-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 -- | Test suite.
 
@@ -6,8 +7,8 @@
 
 import Control.Applicative
 import Control.Monad
+import Data.Aeson
 import Data.Maybe
-import Data.Monoid
 import Path
 import Path.Internal
 import Test.Hspec
@@ -29,6 +30,7 @@
      describe "Operations: parent" operationParent
      describe "Operations: filename" operationFilename
      describe "Restrictions" restrictions
+     describe "Aeson Instances" aesonInstances
 
 -- | Restricting the input of any tricks.
 restrictions :: Spec
@@ -214,12 +216,22 @@
 parserTest parser input expected =
   it ((case expected of
          Nothing -> "Failing: "
-         Just{} -> "Succeeding: ") <>
-      "Parsing " <>
-      show input <>
-      " " <>
+         Just{} -> "Succeeding: ") ++
+      "Parsing " ++
+      show input ++
+      " " ++
       case expected of
         Nothing -> "should fail."
-        Just x -> "should succeed with: " <> show x)
+        Just x -> "should succeed with: " ++ show x)
      (actual == expected)
   where actual = parser input
+
+-- | Tests for the 'ToJSON' and 'FromJSON' instances
+aesonInstances :: Spec
+aesonInstances =
+  do it "Decoding \"[\"/foo/bar\"]\" as a [Path Abs Dir] should succeed." $
+       eitherDecode "[\"/foo/bar\"]" `shouldBe` Right [Path "/foo/bar/" :: 
Path Abs Dir]
+     it "Decoding \"[\"/foo/bar\"]\" as a [Path Rel Dir] should fail." $
+       decode "[\"/foo/bar\"]" `shouldBe` (Nothing :: Maybe [Path Rel Dir])
+     it "Encoding \"[\"/foo/bar/mu.txt\"]\" should succeed." $
+       encode [Path "/foo/bar/mu.txt" :: Path Abs File] `shouldBe` 
"[\"/foo/bar/mu.txt\"]"


Reply via email to