Hello community,

here is the log from the commit of package ghc-validity for openSUSE:Factory 
checked in at 2017-04-14 13:39:09
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-validity (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-validity.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-validity"

Fri Apr 14 13:39:09 2017 rev:2 rq:485173 version:0.3.3.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-validity/ghc-validity.changes        
2017-03-24 02:06:32.792338765 +0100
+++ /work/SRC/openSUSE:Factory/.ghc-validity.new/ghc-validity.changes   
2017-04-14 13:39:10.331086153 +0200
@@ -1,0 +2,20 @@
+Wed Mar 22 09:16:55 UTC 2017 - psim...@suse.com
+
+- Update to version 0.3.3.0 with cabal2obs.
+
+-------------------------------------------------------------------
+Fri Feb 24 10:34:34 UTC 2017 - psim...@suse.com
+
+- Update to version 0.3.2.0 with cabal2obs.
+
+-------------------------------------------------------------------
+Thu Jan 26 16:20:15 UTC 2017 - psim...@suse.com
+
+- Update to version 0.3.1.1 with cabal2obs.
+
+-------------------------------------------------------------------
+Wed Dec 28 12:14:21 UTC 2016 - psim...@suse.com
+
+- Update to version 0.3.0.4 revision 1 with cabal2obs.
+
+-------------------------------------------------------------------

Old:
----
  validity-0.3.0.4.tar.gz

New:
----
  validity-0.3.3.0.tar.gz

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

Other differences:
------------------
++++++ ghc-validity.spec ++++++
--- /var/tmp/diff_new_pack.z6o7CV/_old  2017-04-14 13:39:11.242957278 +0200
+++ /var/tmp/diff_new_pack.z6o7CV/_new  2017-04-14 13:39:11.246956712 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package ghc-validity
 #
-# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %global pkg_name validity
 Name:           ghc-%{pkg_name}
-Version:        0.3.0.4
+Version:        0.3.3.0
 Release:        0
 Summary:        Validity typeclass
 License:        MIT
@@ -30,12 +30,20 @@
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 
 %description
+For more info, see <https://github.com/NorfairKing/validity the readme>.
+
 Note: There are companion instance packages for this library:
 
 * <https://hackage.haskell.org/package/validity-text validity-text>
 
-* <https://hackage.haskell.org/package/validity-containers
-validity-containers>.
+* <https://hackage.haskell.org/package/validity-path validity-path>
+
+* <https://hackage.haskell.org/package/validity-time validity-time>
+
+* <https://hackage.haskell.org/package/validity-containers validity-containers>
+
+* <https://hackage.haskell.org/package/validity-bytestring
+validity-bytestring>.
 
 %package devel
 Summary:        Haskell %{pkg_name} library development files

++++++ validity-0.3.0.4.tar.gz -> validity-0.3.3.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/validity-0.3.0.4/Setup.hs 
new/validity-0.3.3.0/Setup.hs
--- old/validity-0.3.0.4/Setup.hs       2016-07-13 23:59:26.000000000 +0200
+++ new/validity-0.3.3.0/Setup.hs       2017-02-19 22:34:59.000000000 +0100
@@ -1,2 +1,3 @@
 import Distribution.Simple
+
 main = defaultMain
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/validity-0.3.0.4/src/Data/RelativeValidity.hs 
new/validity-0.3.3.0/src/Data/RelativeValidity.hs
--- old/validity-0.3.0.4/src/Data/RelativeValidity.hs   2016-09-18 
23:31:51.000000000 +0200
+++ new/validity-0.3.3.0/src/Data/RelativeValidity.hs   2017-03-17 
15:18:14.000000000 +0100
@@ -1,15 +1,13 @@
-{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 
 {-| Relative validity
     -}
-
 module Data.RelativeValidity
     ( RelativeValidity(..)
     , isInvalidFor
     ) where
 
-
 -- | A class of types that have additional invariants defined upon them
 -- that aren't enforced by the type system
 --
@@ -21,5 +19,7 @@
 class RelativeValidity a b where
     isValidFor :: a -> b -> Bool
 
-isInvalidFor :: RelativeValidity a b => a -> b -> Bool
+isInvalidFor
+    :: RelativeValidity a b
+    => a -> b -> Bool
 isInvalidFor a b = not $ isValidFor a b
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/validity-0.3.0.4/src/Data/Validity.hs 
new/validity-0.3.3.0/src/Data/Validity.hs
--- old/validity-0.3.0.4/src/Data/Validity.hs   2016-09-18 23:31:51.000000000 
+0200
+++ new/validity-0.3.3.0/src/Data/Validity.hs   2017-03-17 16:47:32.000000000 
+0100
@@ -1,4 +1,8 @@
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE TypeOperators #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE DefaultSignatures #-}
 
 {-|
 
@@ -9,7 +13,7 @@
     Suppose we were to implement a type @Prime@ that represents prime integers.
 
     If you were to completely enforce the invariant that the represented 
number is
-    a prime, then we could use @Numeric.Natural@ and only store the index of 
the
+    a prime, then we could use 'Natural' and only store the index of the
     given prime in the infinite sequence of prime numbers.
     This is very safe but also very expensive if we ever want to use the 
number,
     because we would have to calculcate all the prime numbers until that index.
@@ -24,8 +28,12 @@
 
     > instance Validity Prime where
     >     isValid (Prime n) = isPrime n
-    -}
 
+    If certain typeclass invariants exist, you can make these explicit in the
+    validity instance as well.
+    For example, 'Fixed a' is only valid if 'a' has an 'HasResolution' 
instance,
+    so the correct validity instance is @HasResolution a => Validity (Fixed 
a)@.
+    -}
 module Data.Validity
     ( Validity(..)
     , isInvalid
@@ -33,24 +41,63 @@
     , constructValidUnsafe
     ) where
 
-import           Data.Maybe (fromMaybe)
-
+import Data.Fixed (Fixed(MkFixed), HasResolution)
+import Data.Maybe (Maybe, fromMaybe)
+import Data.Word (Word, Word8, Word16)
+import GHC.Generics
+#if MIN_VERSION_base(4,8,0)
+import GHC.Natural (Natural, isValidNatural)
+#endif
+import GHC.Real (Ratio(..))
 
 -- | A class of types that have additional invariants defined upon them
 -- that aren't enforced by the type system
+--
+-- 'isValid' should be an underapproximation of actual validity.
+--
+-- This means that if 'isValid' is not a perfect representation of actual
+-- validity, for safety reasons, it should never return 'True' for invalid
+-- values, but it may return 'False' for valid values.
+--
+-- For example:
+--
+-- > isValid = const False
+--
+-- is a valid implementation for any type, because it never returns 'True'
+-- for invalid values.
+--
+-- > isValid (Even i) = i == 2
+--
+-- is a valid implementation for @newtype Even = Even Int@, but
+--
+-- > isValid (Even i) = even i || i == 1
+--
+-- is not because it returns 'True' for an invalid value: '1'.
 class Validity a where
-    -- | Check whether a given value is a valid value.
     isValid :: a -> Bool
-
-isInvalid :: Validity a => a -> Bool
+    default isValid :: (Generic a, GValidity (Rep a)) =>
+        a -> Bool
+    isValid = gIsValid . from
+
+isInvalid
+    :: Validity a
+    => a -> Bool
 isInvalid = not . isValid
 
 -- | Any tuple of things is valid if both of its elements are valid
-instance (Validity a, Validity b) => Validity (a, b) where
+instance (Validity a, Validity b) =>
+         Validity (a, b) where
     isValid (a, b) = isValid a && isValid b
 
+-- | Any Either of things is valid if the contents are valid in either of the 
cases.
+instance (Validity a, Validity b) =>
+         Validity (Either a b) where
+    isValid (Left a) = isValid a
+    isValid (Right b) = isValid b
+
 -- | Any tuple of things is valid if all three of its elements are valid
-instance (Validity a, Validity b, Validity c) => Validity (a, b, c) where
+instance (Validity a, Validity b, Validity c) =>
+         Validity (a, b, c) where
     isValid (a, b, c) = isValid a && isValid b && isValid c
 
 -- | A list of things is valid if all of the things are valid.
@@ -58,14 +105,16 @@
 -- This means that the empty list is considered valid.
 -- If the empty list should not be considered valid as part of your custom data
 -- type, make sure to write a custom @Validity instance@
-instance Validity a => Validity [a] where
+instance Validity a =>
+         Validity [a] where
     isValid = all isValid
 
 -- | A Maybe thing is valid if the thing inside is valid or it's nothing
 -- It makes sense to assume that 'Nothing' is valid.
 -- If Nothing wasn't valid, you wouldn't have used a Maybe
 -- in the datastructure.
-instance Validity a => Validity (Maybe a) where
+instance Validity a =>
+         Validity (Maybe a) where
     isValid Nothing = True
     isValid (Just a) = isValid a
 
@@ -93,34 +142,91 @@
 instance Validity Word where
     isValid = const True
 
+-- | Trivially valid
+instance Validity Word8 where
+    isValid = const True
+
+-- | Trivially valid
+instance Validity Word16 where
+    isValid = const True
+
 -- | NOT trivially valid:
 --
 -- * NaN is not valid.
 -- * Infinite values are not valid.
 instance Validity Float where
-    isValid d
-      =  not (isNaN d)
-      && not (isInfinite d)
+    isValid d = not (isNaN d) && not (isInfinite d)
 
 -- | NOT trivially valid:
 --
 -- * NaN is not valid.
 -- * Infinite values are not valid.
 instance Validity Double where
-    isValid d
-      =  not (isNaN d)
-      && not (isInfinite d)
+    isValid d = not (isNaN d) && not (isInfinite d)
 
 -- | Trivially valid
+--
+-- Integer is not trivially valid under the hood, but instantiating
+-- 'Validity' correctly would force validity to depend on a specific
+-- (big integer library @integer-gmp@ versus @integer-simple@).
+-- This is rather impractical so for the time being we have opted for
+-- assuming that an 'Integer' is always valid.
+-- Even though this is not technically sound, it is good enough for now.
 instance Validity Integer where
     isValid = const True
+#if MIN_VERSION_base(4,8,0)
+-- | Valid according to 'isValidNatural'
+--
+-- Only available with @base >= 4.8@.
+instance Validity Natural where
+    isValid = isValidNatural
+#endif
+-- | Valid if the contained 'Integer's are valid and the denominator is
+-- strictly positive.
+instance Validity Rational where
+    isValid (d :% n) = and [isValid n, isValid d, d > 0]
+
+-- | Valid according to the contained 'Integer'.
+instance HasResolution a =>
+         Validity (Fixed a) where
+    isValid (MkFixed i) = isValid i
 
 -- | Construct a valid element from an unchecked element
-constructValid :: Validity a => a -> Maybe a
-constructValid p = if isValid p then Just p else Nothing
+constructValid
+    :: Validity a
+    => a -> Maybe a
+constructValid p =
+    if isValid p
+        then Just p
+        else Nothing
 
 -- | Construct a valid element from an unchecked element, throwing 'error'
 -- on invalid elements.
-constructValidUnsafe :: (Show a, Validity a) => a -> a
-constructValidUnsafe p = fromMaybe (error $ show p ++ " is not valid") $ 
constructValid p
-
+constructValidUnsafe
+    :: (Show a, Validity a)
+    => a -> a
+constructValidUnsafe p =
+    fromMaybe (error $ show p ++ " is not valid") $ constructValid p
+
+class GValidity f where
+    gIsValid :: f a -> Bool
+
+instance GValidity U1 where
+    gIsValid U1 = True
+
+instance (GValidity a, GValidity b) =>
+         GValidity (a :*: b) where
+    gIsValid (a :*: b) = gIsValid a && gIsValid b
+
+instance (GValidity a, GValidity b) =>
+         GValidity (a :+: b) where
+    gIsValid (L1 x) = gIsValid x
+    gIsValid (R1 x) = gIsValid x
+
+instance (GValidity a) =>
+         GValidity (M1 i c a) where
+    gIsValid (M1 x) = gIsValid x
+
+instance (Validity a) =>
+         GValidity (K1 i a) where
+    gIsValid (K1 x) = isValid x
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/validity-0.3.0.4/validity.cabal 
new/validity-0.3.3.0/validity.cabal
--- old/validity-0.3.0.4/validity.cabal 2016-09-30 01:09:13.000000000 +0200
+++ new/validity-0.3.3.0/validity.cabal 2017-03-17 16:47:32.000000000 +0100
@@ -1,31 +1,41 @@
-name:                validity
-version:             0.3.0.4
-synopsis:            Validity typeclass
+name: validity
+version: 0.3.3.0
+cabal-version: >=1.10
+build-type: Simple
+license: MIT
+license-file: LICENSE
+copyright: Copyright: (c) 2016 Tom Sydney Kerckhove
+maintainer: syd.kerckh...@gmail.com
+homepage: https://github.com/NorfairKing/validity#readme
+synopsis: Validity typeclass
 description:
-  Note: There are companion instance packages for this library:
-  .
-  * <https://hackage.haskell.org/package/validity-text validity-text>
-  .
-  * <https://hackage.haskell.org/package/validity-containers 
validity-containers>
+    For more info, see <https://github.com/NorfairKing/validity the readme>.
+    .
+    Note: There are companion instance packages for this library:
+    .
+    * <https://hackage.haskell.org/package/validity-text validity-text>
+    .
+    * <https://hackage.haskell.org/package/validity-path validity-path>
+    .
+    * <https://hackage.haskell.org/package/validity-time validity-time>
+    .
+    * <https://hackage.haskell.org/package/validity-containers 
validity-containers>
+    .
+    * <https://hackage.haskell.org/package/validity-bytestring 
validity-bytestring>
+category: Validity
+author: Tom Sydney Kerckhove
 
-homepage:            https://github.com/NorfairKing/validity#readme
-license:             MIT
-license-file:        LICENSE
-author:              Tom Sydney Kerckhove
-maintainer:          syd.kerckh...@gmail.com
-copyright:           Copyright: (c) 2016 Tom Sydney Kerckhove
-category:            Web
-build-type:          Simple
--- extra-source-files:
-cabal-version:       >=1.10
+source-repository head
+    type: git
+    location: https://github.com/NorfairKing/validity
 
 library
-  hs-source-dirs:      src
-  exposed-modules:     Data.Validity
-                     , Data.RelativeValidity
-  build-depends:       base >= 4 && < 5
-  default-language:    Haskell2010
-
-source-repository head
-  type:     git
-  location: https://github.com/NorfairKing/validity
+    exposed-modules:
+        Data.RelativeValidity
+        Data.Validity
+    build-depends:
+        base >=4.7 && <5
+    default-language: Haskell2010
+    hs-source-dirs: src
+    if impl(ghc >= 8.0.0)
+        ghc-options: -Wno-redundant-constraints


Reply via email to