on master help sign in
Merge pull request #61 from haskell-hvr/bs-random
7cb2f5bOleg Grenrus
.github/workflows/haskell-ci-bench.yml+9
@@ -175,3 +175,12 @@ jobs:
175 run: |
175 run: |
176 rm -f cabal.project.local
176 rm -f cabal.project.local
177 $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
177 $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:
194 run: |
194 run: |
195 rm -f cabal.project.local
195 rm -f cabal.project.local
196 $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
196 $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 @@
1branches: master
1branches: 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
33library
33library
34 build-depends:
34 build-depends:
35 base >=4.9 && <5
35 base >=4.9 && <5
36− , binary >=0.4 && <0.9
36+ , binary >=0.5.1.0 && <0.9
37− , bytestring >=0.9 && <0.11
37+ , bytestring >=0.9.2.1 && <0.12
38 , cryptohash-md5 >=0.11.100 && <0.12
38 , cryptohash-md5 >=0.11.100 && <0.12
39 , cryptohash-sha1 >=0.11.100 && <0.12
39 , cryptohash-sha1 >=0.11.100 && <0.12
40− , deepseq >=1.3 && <1.5
40+ , deepseq >=1.3.0.0 && <1.5
41 , entropy >=0.3.7 && <0.5
41 , entropy >=0.3.7 && <0.5
42 , hashable >=1.2.7.0 && <1.4
42 , hashable >=1.2.7.0 && <1.4
43 , network-info >=0.2 && <0.3
43 , network-info >=0.2 && <0.3
44− , random >=1.0.1 && <1.2
44+ , random >=1.1 && <1.3
45− , text >=1.2.3 && <1.3
45+ , text >=1.2.3.0 && <1.3
46− , time >=1.1 && <1.12
46+ , time >=1.4 && <1.12
47− , uuid-types >=1.0.2 && <2
48
47
49 -- uuid modules
48 -- uuid modules
50 exposed-modules:
49 exposed-modules:
uuid-types/src/Data/UUID/Types/Internal.hs+19−1
@@ -72,7 +72,12 @@ import qualified Data.Text.Encoding as T
72
72
73import Data.UUID.Types.Internal.Builder
73import Data.UUID.Types.Internal.Builder
74
74
75+#if MIN_VERSION_random(1,2,0)
76+import System.Random (Random (..), uniform)
77+import System.Random.Stateful (Uniform (..), uniformWord64)
78+#else
75−import System.Random
79+import System.Random (Random (..), next)
80+#endif
76
81
77
82
78-- | Type representing <https://en.wikipedia.org/wiki/UUID Universally Unique Identifiers (UUID)> as specified in
83-- | Type representing <https://en.wikipedia.org/wiki/UUID Universally Unique Identifiers (UUID)> as specified in
@@ -480,6 +485,18 @@ fromLazyASCIIBytes bs =
480
485
481-- | This 'Random' instance produces __insecure__ version 4 UUIDs as
486-- | This 'Random' instance produces __insecure__ version 4 UUIDs as
482-- specified in <http://tools.ietf.org/html/rfc4122 RFC 4122>.
487-- 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
483instance Random UUID where
500instance Random UUID where
484 random g = (fromGenNext w0 w1 w2 w3 w4, g4)
501 random g = (fromGenNext w0 w1 w2 w3 w4, g4)
485 where (w0, g0) = next g
502 where (w0, g0) = next g
@@ -501,6 +518,7 @@ fromGenNext w0 w1 w2 w3 w4 =
501 -- field will "cover" the upper, non-random bits
518 -- field will "cover" the upper, non-random bits
502 /-/ (ThreeByte w3)
519 /-/ (ThreeByte w3)
503 /-/ (ThreeByte w4)
520 /-/ (ThreeByte w4)
521+#endif
504
522
505-- |A ByteSource to extract only three bytes from an Int, since next on StdGet
523-- |A ByteSource to extract only three bytes from an Int, since next on StdGet
506-- only returns 31 bits of randomness.
524-- only returns 31 bits of randomness.
uuid-types/uuid-types.cabal+7−7
@@ -1,6 +1,6 @@
1cabal-version: 1.12
1cabal-version: 1.12
2name: uuid-types
2name: uuid-types
3−version: 1.0.4.0
3+version: 1.0.4
4copyright:
4copyright:
5 (c) 2017-2018 Herbert Valerio Riedel
5 (c) 2017-2018 Herbert Valerio Riedel
6 (c) 2008-2014 Antoine Latter
6 (c) 2008-2014 Antoine Latter
@@ -45,13 +45,13 @@ source-repository head
45
45
46library
46library
47 build-depends:
47 build-depends:
48− base >=4.3 && <5
48+ base >=4.5 && <5
49− , binary >=0.4 && <0.9
49+ , binary >=0.5.1.0 && <0.9
50− , bytestring >=0.9 && <0.11
50+ , bytestring >=0.9.2.1 && <0.12
51− , deepseq >=1.3 && <1.5
51+ , deepseq >=1.3.0.0 && <1.5
52 , hashable >=1.2.7.0 && <1.4
52 , hashable >=1.2.7.0 && <1.4
53− , random >=1.1 && <1.2
53+ , random >=1.1 && <1.3
54− , text >=1.2.3 && <1.3
54+ , text >=1.2.3.0 && <1.3
55
55
56 exposed-modules: Data.UUID.Types
56 exposed-modules: Data.UUID.Types
57
57
uuid/uuid.cabal+6−6
@@ -40,16 +40,16 @@ source-repository head
40
40
41library
41library
42 build-depends:
42 build-depends:
43− base >=4.3 && <5
43+ base >=4.5 && <5
44− , binary >=0.4 && <0.9
44+ , binary >=0.5.1.0 && <0.9
45− , bytestring >=0.9 && <0.11
45+ , bytestring >=0.9.2.1 && <0.12
46 , cryptohash-md5 >=0.11.100 && <0.12
46 , cryptohash-md5 >=0.11.100 && <0.12
47 , cryptohash-sha1 >=0.11.100 && <0.12
47 , cryptohash-sha1 >=0.11.100 && <0.12
48 , entropy >=0.3.7 && <0.5
48 , entropy >=0.3.7 && <0.5
49 , network-info >=0.2 && <0.3
49 , network-info >=0.2 && <0.3
50− , random >=1.1 && <1.2
50+ , random >=1.1 && <1.3
51− , text >=1.2.3 && <1.3
51+ , text >=1.2.3.0 && <1.3
52− , time >=1.1 && <1.12
52+ , time >=1.4 && <1.12
53 , uuid-types >=1.0.2 && <2
53 , uuid-types >=1.0.2 && <2
54
54
55 exposed-modules:
55 exposed-modules: