on master help sign in
Merge pull request #61 from haskell-hvr/bs-random

Adjust lower bounds, allow bytestring-0.11 and random-1.2

commit7cb2f5b6f898fa073c3f0b9e13b249a17cebad8d authorOleg Grenrus <oleg.grenrus@iki.fi> dateWed 17 Feb 2021, 01:21 (6 years ago) parentdcaad668eb4b5c
7 files changed+63−21
.github/workflows/haskell-ci-bench.yml+9 .github/workflows/haskell-ci.yml+9 cabal.haskell-ci+7 uuid-bench/uuid-bench.cabal+6−7 uuid-types/src/Data/UUID/Types/Internal.hs+19−1 uuid-types/uuid-types.cabal+7−7 uuid/uuid.cabal+6−6
.github/workflows/haskell-ci-bench.yml+9
@@ -175,3 +175,12 @@ jobs:
175175 run: |
176176 rm -f cabal.project.local
177177 $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
178+ - name: prepare for constraint sets
179+ run: |
180+ rm -f cabal.project.local
181+ - name: constraint set random-1.2
182+ run: |
183+ $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='random==1.2.*' all
184+ - name: constraint set random-1.1
185+ run: |
186+ $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='random==1.1.*' all
.github/workflows/haskell-ci.yml+9
@@ -194,3 +194,12 @@ jobs:
194194 run: |
195195 rm -f cabal.project.local
196196 $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
197+ - name: prepare for constraint sets
198+ run: |
199+ rm -f cabal.project.local
200+ - name: constraint set random-1.2
201+ run: |
202+ if [ $((HCNUMVER >= 71000)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='random==1.2.*' all ; fi
203+ - name: constraint set random-1.1
204+ run: |
205+ $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='random==1.1.*' all
cabal.haskell-ci+7
@@ -1 +1,8 @@
11branches: master
2+
3+constraint-set random-1.1
4+ constraints: random==1.1.*
5+
6+constraint-set random-1.2
7+ ghc: >=7.10
8+ constraints: random==1.2.*
uuid-bench/uuid-bench.cabal+6−7
@@ -33,18 +33,17 @@ source-repository head
3333library
3434 build-depends:
3535 base >=4.9 && <5
36− , binary >=0.4 && <0.9
37− , bytestring >=0.9 && <0.11
36+ , binary >=0.5.1.0 && <0.9
37+ , bytestring >=0.9.2.1 && <0.12
3838 , cryptohash-md5 >=0.11.100 && <0.12
3939 , cryptohash-sha1 >=0.11.100 && <0.12
40− , deepseq >=1.3 && <1.5
40+ , deepseq >=1.3.0.0 && <1.5
4141 , entropy >=0.3.7 && <0.5
4242 , hashable >=1.2.7.0 && <1.4
4343 , network-info >=0.2 && <0.3
44− , random >=1.0.1 && <1.2
45− , text >=1.2.3 && <1.3
46− , time >=1.1 && <1.12
47− , uuid-types >=1.0.2 && <2
44+ , random >=1.1 && <1.3
45+ , text >=1.2.3.0 && <1.3
46+ , time >=1.4 && <1.12
4847
4948 -- uuid modules
5049 exposed-modules:
uuid-types/src/Data/UUID/Types/Internal.hs+19−1
@@ -72,7 +72,12 @@ import qualified Data.Text.Encoding as T
7272
7373import Data.UUID.Types.Internal.Builder
7474
75−import System.Random
75+#if MIN_VERSION_random(1,2,0)
76+import System.Random (Random (..), uniform)
77+import System.Random.Stateful (Uniform (..), uniformWord64)
78+#else
79+import System.Random (Random (..), next)
80+#endif
7681
7782
7883-- | Type representing <https://en.wikipedia.org/wiki/UUID Universally Unique Identifiers (UUID)> as specified in
@@ -480,6 +485,18 @@ fromLazyASCIIBytes bs =
480485
481486-- | This 'Random' instance produces __insecure__ version 4 UUIDs as
482487-- specified in <http://tools.ietf.org/html/rfc4122 RFC 4122>.
488+#if MIN_VERSION_random(1,2,0)
489+instance Random UUID where
490+ random = uniform
491+ randomR _ = random -- range is ignored
492+
493+-- @since 1.0.4
494+instance Uniform UUID where
495+ uniformM gen = do
496+ w0 <- uniformWord64 gen
497+ w1 <- uniformWord64 gen
498+ pure $ buildFromBytes 4 /-/ w0 /-/ w1
499+#else
483500instance Random UUID where
484501 random g = (fromGenNext w0 w1 w2 w3 w4, g4)
485502 where (w0, g0) = next g
@@ -501,6 +518,7 @@ fromGenNext w0 w1 w2 w3 w4 =
501518 -- field will "cover" the upper, non-random bits
502519 /-/ (ThreeByte w3)
503520 /-/ (ThreeByte w4)
521+#endif
504522
505523-- |A ByteSource to extract only three bytes from an Int, since next on StdGet
506524-- only returns 31 bits of randomness.
uuid-types/uuid-types.cabal+7−7
@@ -1,6 +1,6 @@
11cabal-version: 1.12
22name: uuid-types
3−version: 1.0.4.0
3+version: 1.0.4
44copyright:
55 (c) 2017-2018 Herbert Valerio Riedel
66 (c) 2008-2014 Antoine Latter
@@ -45,13 +45,13 @@ source-repository head
4545
4646library
4747 build-depends:
48− base >=4.3 && <5
49− , binary >=0.4 && <0.9
50− , bytestring >=0.9 && <0.11
51− , deepseq >=1.3 && <1.5
48+ base >=4.5 && <5
49+ , binary >=0.5.1.0 && <0.9
50+ , bytestring >=0.9.2.1 && <0.12
51+ , deepseq >=1.3.0.0 && <1.5
5252 , hashable >=1.2.7.0 && <1.4
53− , random >=1.1 && <1.2
54− , text >=1.2.3 && <1.3
53+ , random >=1.1 && <1.3
54+ , text >=1.2.3.0 && <1.3
5555
5656 exposed-modules: Data.UUID.Types
5757
uuid/uuid.cabal+6−6
@@ -40,16 +40,16 @@ source-repository head
4040
4141library
4242 build-depends:
43− base >=4.3 && <5
44− , binary >=0.4 && <0.9
45− , bytestring >=0.9 && <0.11
43+ base >=4.5 && <5
44+ , binary >=0.5.1.0 && <0.9
45+ , bytestring >=0.9.2.1 && <0.12
4646 , cryptohash-md5 >=0.11.100 && <0.12
4747 , cryptohash-sha1 >=0.11.100 && <0.12
4848 , entropy >=0.3.7 && <0.5
4949 , network-info >=0.2 && <0.3
50− , random >=1.1 && <1.2
51− , text >=1.2.3 && <1.3
52− , time >=1.1 && <1.12
50+ , random >=1.1 && <1.3
51+ , text >=1.2.3.0 && <1.3
52+ , time >=1.4 && <1.12
5353 , uuid-types >=1.0.2 && <2
5454
5555 exposed-modules: