Hello community,
here is the log from the commit of package ghc-generic-random for
openSUSE:Factory checked in at 2017-08-31 20:47:08
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-generic-random (Old)
and /work/SRC/openSUSE:Factory/.ghc-generic-random.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-generic-random"
Thu Aug 31 20:47:08 2017 rev:2 rq:513245 version:0.5.0.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-generic-random/ghc-generic-random.changes
2017-06-12 15:27:52.366938725 +0200
+++
/work/SRC/openSUSE:Factory/.ghc-generic-random.new/ghc-generic-random.changes
2017-08-31 20:47:09.777778660 +0200
@@ -1,0 +2,10 @@
+Fri Jul 28 03:01:23 UTC 2017 - [email protected]
+
+- Update to version 0.5.0.0 revision 2.
+
+-------------------------------------------------------------------
+Thu Jul 27 14:06:57 UTC 2017 - [email protected]
+
+- Update to version 0.5.0.0 revision 1.
+
+-------------------------------------------------------------------
Old:
----
generic-random-0.4.1.0.tar.gz
New:
----
generic-random-0.5.0.0.tar.gz
generic-random.cabal
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ ghc-generic-random.spec ++++++
--- /var/tmp/diff_new_pack.Sa7dhr/_old 2017-08-31 20:47:10.721646174 +0200
+++ /var/tmp/diff_new_pack.Sa7dhr/_new 2017-08-31 20:47:10.725645614 +0200
@@ -18,16 +18,16 @@
%global pkg_name generic-random
Name: ghc-%{pkg_name}
-Version: 0.4.1.0
+Version: 0.5.0.0
Release: 0
Summary: Generic random generators
License: MIT
Group: Development/Languages/Other
Url: https://hackage.haskell.org/package/%{pkg_name}
Source0:
https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
+Source1:
https://hackage.haskell.org/package/%{pkg_name}-%{version}/revision/2.cabal#/%{pkg_name}.cabal
BuildRequires: ghc-Cabal-devel
BuildRequires: ghc-QuickCheck-devel
-BuildRequires: ghc-boltzmann-samplers-devel
BuildRequires: ghc-rpm-macros
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@@ -47,6 +47,7 @@
%prep
%setup -q -n %{pkg_name}-%{version}
+cp -p %{SOURCE1} %{pkg_name}.cabal
%build
%ghc_lib_build
++++++ generic-random-0.4.1.0.tar.gz -> generic-random-0.5.0.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/generic-random-0.4.1.0/CHANGELOG.md
new/generic-random-0.5.0.0/CHANGELOG.md
--- old/generic-random-0.4.1.0/CHANGELOG.md 2017-03-05 21:30:37.000000000
+0100
+++ new/generic-random-0.5.0.0/CHANGELOG.md 2017-04-10 17:25:58.000000000
+0200
@@ -1,3 +1,9 @@
+# 0.5.0.0
+
+- Turn off dependency on boltzmann-samplers by default
+- Add genericArbitraryU, genericArbitraryU0 and genericArbitraryU1
+- Compatible with GHC 7.8.4 and GHC 7.10.3
+
# 0.4.1.0
- Move Boltzmann sampler modules to another package: boltzmann-samplers
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/generic-random-0.4.1.0/generic-random.cabal
new/generic-random-0.5.0.0/generic-random.cabal
--- old/generic-random-0.4.1.0/generic-random.cabal 2017-03-05
21:30:37.000000000 +0100
+++ new/generic-random-0.5.0.0/generic-random.cabal 2017-04-10
17:25:58.000000000 +0200
@@ -1,5 +1,5 @@
name: generic-random
-version: 0.4.1.0
+version: 0.5.0.0
synopsis: Generic random generators
description: Please see the README.
homepage: http://github.com/lysxia/generic-random
@@ -18,7 +18,7 @@
Description:
Dependency on boltzmann-samplers for backwards compatibility.
Manual: False
- Default: True
+ Default: False
library
hs-source-dirs: src
@@ -26,7 +26,7 @@
Generic.Random.Generic
Generic.Random.Internal.Generic
build-depends:
- base >= 4.9 && < 4.10,
+ base >= 4.7 && < 4.10,
QuickCheck
if flag(boltzmann)
exposed-modules:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/generic-random-0.4.1.0/src/Generic/Random/Generic.hs
new/generic-random-0.5.0.0/src/Generic/Random/Generic.hs
--- old/generic-random-0.4.1.0/src/Generic/Random/Generic.hs 2017-03-05
21:30:37.000000000 +0100
+++ new/generic-random-0.5.0.0/src/Generic/Random/Generic.hs 2017-04-10
17:25:58.000000000 +0200
@@ -27,7 +27,9 @@
--
-- The list of weights is built up with the @('%')@ operator as a cons, and
using
-- the unit @()@ as the empty list, in the order corresponding to the data type
--- definition.
+-- definition. The uniform distribution can be obtained with 'uniform'.
+--
+-- === Example
--
-- For @Tree@, 'genericArbitrary' produces code equivalent to the following:
--
@@ -40,6 +42,20 @@
-- ]
-- @
--
+-- === Uniform distribution
+--
+-- You can specify the uniform distribution (all weights equal) with 'uniform'.
+-- 'genericArbitraryU' is available as a shorthand for
+-- @'genericArbitrary' 'uniform'@.
+--
+-- Note that for many types, a uniform distribution tends to produce big
+-- values. For instance for @Tree a@, generated values are finite but the
+-- __average__ number of @Leaf@ and @Node@ constructors is __infinite__.
+--
+-- === Checked weights
+--
+-- /GHC 8.0.1 and above only./
+--
-- The weights actually have type @'W' \"ConstructorName\"@ (just a newtype
-- around 'Int'), so that you can annotate a weight with its corresponding
-- constructor, and it will be checked that you got the order right.
@@ -60,26 +76,6 @@
-- 'weighted' (x '%' y '%' z '%' ()) :: 'Weights' (Tree a)
-- @
--
--- === Uniform distribution
---
--- You can specify the uniform distribution with 'uniform'.
---
--- For @Tree@, @'genericArbitrary' 'uniform'@ produces code equivalent to the
--- following:
---
--- @
--- 'genericArbitrary' 'uniform' :: Arbitrary a => Gen (Tree a)
--- 'genericArbitrary' 'uniform' =
--- oneof
--- [ Leaf \<$\> arbitrary -- Uses Arbitrary a
--- , Node \<$\> arbitrary \<*\> arbitrary -- Uses Arbitrary (Tree a)
--- ]
--- @
---
--- Note that for many types, a uniform distribution tends to produce big
--- values. For instance for @Tree a@, generated values are finite but the
--- __average__ number of @Leaf@ and @Node@ constructors is __infinite__.
---
-- == Ensuring termination
--
-- As was just mentioned, one must be careful with recursive types
@@ -191,7 +187,10 @@
(
-- * Arbitrary implementations
genericArbitrary
+ , genericArbitraryU
, genericArbitrary'
+ , genericArbitraryU0
+ , genericArbitraryU1
-- * Specifying finite distributions
, Weights
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/generic-random-0.4.1.0/src/Generic/Random/Internal/Generic.hs
new/generic-random-0.5.0.0/src/Generic/Random/Internal/Generic.hs
--- old/generic-random-0.4.1.0/src/Generic/Random/Internal/Generic.hs
2017-03-05 21:30:37.000000000 +0100
+++ new/generic-random-0.5.0.0/src/Generic/Random/Internal/Generic.hs
2017-04-10 17:25:58.000000000 +0200
@@ -1,4 +1,5 @@
{-# LANGUAGE ConstraintKinds #-}
+{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleContexts #-}
@@ -15,8 +16,8 @@
import Control.Applicative
import Data.Coerce
-import GHC.Exts (Proxy#, proxy#)
-import GHC.Generics hiding ( S )
+import Data.Proxy
+import GHC.Generics hiding (S, Arity)
import GHC.TypeLits
import Test.QuickCheck
@@ -27,12 +28,19 @@
genericArbitrary
:: forall a
. (Generic a, GA Unsized (Rep a))
- => Weights a
+ => Weights a -- ^ List of weights for every constructor
-> Gen a
genericArbitrary (Weights w n) = (unGen' . fmap to) (ga w n :: Gen' Unsized
(Rep a p))
--- | Like 'genericArbitrary'', with bounded size to ensure termination for
--- recursive types.
+-- | Shorthand for @'genericArbitrary' 'uniform'@.
+genericArbitraryU
+ :: forall a
+ . (Generic a, GA Unsized (Rep a), UniformWeight (Weights_ (Rep a)))
+ => Gen a
+genericArbitraryU = genericArbitrary uniform
+
+-- | Like 'genericArbitrary'', with decreasing size to ensure termination for
+-- recursive types, looking for base cases once the size reaches 0.
genericArbitrary'
:: forall n a
. (Generic a, GA (Sized n) (Rep a))
@@ -42,13 +50,32 @@
genericArbitrary' _ (Weights w n) =
(unGen' . fmap to) (ga w n :: Gen' (Sized n) (Rep a p))
+-- | Shorthand for @'genericArbitrary'' 'Z' 'uniform'@, using nullary
+-- constructors as the base cases.
+genericArbitraryU0
+ :: forall n a
+ . (Generic a, GA (Sized Z) (Rep a), UniformWeight (Weights_ (Rep a)))
+ => Gen a
+genericArbitraryU0 = genericArbitrary' Z uniform
+
+-- | Shorthand for @'genericArbitrary'' ('S' 'Z') 'uniform'@, using nullary
+-- constructors and constructors whose fields are all nullary as base cases.
+genericArbitraryU1
+ :: forall n a
+ . (Generic a, GA (Sized (S Z)) (Rep a), UniformWeight (Weights_ (Rep a)))
+ => Gen a
+genericArbitraryU1 = genericArbitrary' (S Z) uniform
-- * Internal
type family Weights_ (f :: * -> *) :: * where
Weights_ (f :+: g) = Weights_ f :| Weights_ g
Weights_ (M1 D _c f) = Weights_ f
+#if __GLASGOW_HASKELL__ >= 800
Weights_ (M1 C ('MetaCons c _i _j) _f) = L c
+#else
+ Weights_ (M1 C _c _f) = ()
+#endif
data a :| b = N a Int b
data L (c :: Symbol) = L
@@ -110,6 +137,10 @@
type Prec (L c) r = r
W m % prec = (L, m, prec)
+instance WeightBuilder () where
+ type Prec () r = r
+ W m % prec = ((), m, prec)
+
class UniformWeight a where
uniformWeight :: (a, Int)
@@ -124,6 +155,9 @@
instance UniformWeight (L c) where
uniformWeight = (L, 1)
+instance UniformWeight () where
+ uniformWeight = ((), 1)
+
newtype Gen' sized a = Gen' { unGen' :: Gen a }
deriving (Functor, Applicative, Monad)
@@ -144,9 +178,9 @@
ga _ _ = (Gen' . fmap M1) gaProduct
instance (GAProduct f, KnownNat (Arity f)) => GA (Sized n) (M1 C c f) where
- ga _ _ = Gen' (scale (`div` arity) gaProduct)
+ ga _ _ = Gen' (sized $ \n -> resize (n `div` arity) gaProduct)
where
- arity = fromInteger (natVal' (proxy# :: Proxy# (Arity f)))
+ arity = fromInteger (natVal (Proxy :: Proxy (Arity f)))
instance (GASum (Sized n) f, GASum (Sized n) g, BaseCases n f, BaseCases n g)
=> GA (Sized n) (f :+: g) where
++++++ generic-random.cabal ++++++
name: generic-random
version: 0.5.0.0
x-revision: 2
synopsis: Generic random generators
description:
Please see the README.
Note: this package no longer exports Boltzmann samplers by default although
they appear below.
("Generic.Random.Data", "Generic.Random.Boltzmann")
homepage: http://github.com/lysxia/generic-random
license: MIT
license-file: LICENSE
stability: Experimental
author: Li-yao Xia
maintainer: [email protected]
category: Generics, Testing
build-type: Simple
extra-source-files: README.md CHANGELOG.md
cabal-version: >=1.10
tested-with: GHC == 8.0.1
flag boltzmann
Description:
Dependency on boltzmann-samplers for backwards compatibility.
Manual: False
Default: False
library
hs-source-dirs: src
exposed-modules:
Generic.Random.Generic
Generic.Random.Internal.Generic
build-depends:
base >= 4.7 && < 4.11,
QuickCheck
if flag(boltzmann)
exposed-modules:
Generic.Random.Boltzmann
Generic.Random.Data
build-depends:
boltzmann-samplers <= 0.2
default-language: Haskell2010
ghc-options: -Wall -fno-warn-name-shadowing
source-repository head
type: git
location: https://github.com/lysxia/generic-random