on master help sign in
Split UUID data type out into separate Cabal package
03b5bcfBardur Arantsson
.gitignore+4−4
@@ -1,9 +1,9 @@
1
1
2# Sandboxing
2# Sandboxing
3−/.cabal-sandbox/
3+.cabal-sandbox/
4−/cabal.sandbox.config
4+cabal.sandbox.config
5
5
6# Cabal stuff
6# Cabal stuff
7−/dist/
7+dist/
8−/cabal.config
8+cabal.config
9
9
.travis.yml+4
@@ -5,3 +5,7 @@ ghc:
5 - 7.4
5 - 7.4
6
6
7sudo: false
7sudo: false
8+install:
9+ - ./travis-scripts/install.sh
10+script:
11+ - ./travis-scripts/build.sh
travis-scripts/build.shnew file+27
@@ -0,0 +1,27 @@
1+#!/usr/bin/env sh
2+echo "==========================================="
3+echo "= Building and installing 'uuid-types'... ="
4+echo "==========================================="
5+
6+# We install here because "uuid" is going to need it.
7+(cd "uuid-types" && \
8+ cabal configure --enable-tests && \
9+ cabal build && \
10+ cabal test && \
11+ cabal install) || exit 1
12+
13+echo "========================================="
14+echo "= Installing dependencies for 'uuid'... ="
15+echo "========================================="
16+
17+(cd "uuid" && \
18+ cabal install --dependencies-only --enable-tests) || exit 1
19+
20+echo "======================"
21+echo "= Building 'uuid'... ="
22+echo "======================"
23+
24+(cd "uuid" && \
25+ cabal configure --enable-tests && \
26+ cabal build && \
27+ cabal test) || exit 1
travis-scripts/install.shnew file+13
@@ -0,0 +1,13 @@
1+#!/usr/bin/env sh
2+
3+# We can only pre-install dependencies for the "uuid-types" project
4+# since the "uuid" project depends on "uuid-types". We could use
5+# sandboxing and "add-source", but it seems quite wasteful of
6+# CPU-cycles to compile everything twice for each version of GHC.
7+
8+echo "==============================================="
9+echo "= Installing dependencies for 'uuid-types'... ="
10+echo "==============================================="
11+
12+(cd "uuid-types" && \
13+ cabal install --dependencies-only --enable-tests) || exit 1
uuid-types/CHANGESnew file+3
@@ -0,0 +1,3 @@
1+1.0.0
2+
3+- Initial split from "uuid-1.3.8"
CONTRIBUTORS → uuid-types/CONTRIBUTORSrenamed+2−1
@@ -9,4 +9,5 @@ Bas van Dijk
9Sergei Trofimovich
9Sergei Trofimovich
10davean
10davean
11Francesco Mazzoli
11Francesco Mazzoli
12−Michael Snoyman
12+Michael Snoyman
13+Bardur Arantsson
uuid-types/Data/UUID/Types.hsnew file+37
@@ -0,0 +1,37 @@
1+{- |
2+Module : Data.UUID.Types
3+Copyright : (c) 2008,2012 Antoine Latter
4+
5+License : BSD-style
6+
7+Maintainer : aslatter@gmail.com
8+Stability : experimental
9+Portability : portable
10+
11+
12+This library is useful for comparing, parsing and
13+printing Universally Unique Identifiers.
14+See <http://en.wikipedia.org/wiki/UUID> for the general idea.
15+See <http://tools.ietf.org/html/rfc4122> for the specification.
16+
17+-}
18+module Data.UUID.Types(UUID
19+ ,toString
20+ ,fromString
21+ ,toASCIIBytes
22+ ,fromASCIIBytes
23+ ,toLazyASCIIBytes
24+ ,fromLazyASCIIBytes
25+ ,toByteString
26+ ,fromByteString
27+ ,toWords
28+ ,fromWords
29+ ,null
30+ ,nil
31+ ) where
32+
33+import Prelude () -- we need to hide Prelude.null
34+import Data.UUID.Types.Internal
35+
36+-- Everything is really implemented in Data.UUID.Types.Internal, but I
37+-- don't want to export the constructors out of the package.
Data/UUID/Internal.hs → uuid-types/Data/UUID/Types/Internal.hsrenamed+4−4
@@ -1,7 +1,7 @@
1{-# LANGUAGE DeriveDataTypeable, TypeFamilies, CPP #-}
1{-# LANGUAGE DeriveDataTypeable, TypeFamilies, CPP #-}
2
2
3-- |
3-- |
4−-- Module : Data.UUID
4+-- Module : Data.UUID.Types.Internal
5-- Copyright : (c) 2008-2009, 2012 Antoine Latter
5-- Copyright : (c) 2008-2009, 2012 Antoine Latter
6-- (c) 2009 Mark Lentczner
6-- (c) 2009 Mark Lentczner
7--
7--
@@ -11,7 +11,7 @@
11-- Stability : experimental
11-- Stability : experimental
12-- Portability : portable
12-- Portability : portable
13
13
14−module Data.UUID.Internal
14+module Data.UUID.Types.Internal
15 (UUID(..)
15 (UUID(..)
16 ,null
16 ,null
17 ,nil
17 ,nil
@@ -61,7 +61,7 @@ import qualified Data.ByteString.Internal as BI
61import qualified Data.ByteString.Lazy as BL
61import qualified Data.ByteString.Lazy as BL
62import qualified Data.ByteString.Unsafe as BU
62import qualified Data.ByteString.Unsafe as BU
63
63
64−import Data.UUID.Builder
64+import Data.UUID.Types.Internal.Builder
65
65
66import System.Random
66import System.Random
67
67
@@ -528,7 +528,7 @@ instance Data UUID where
528 dataTypeOf _ = uuidType
528 dataTypeOf _ = uuidType
529
529
530uuidType :: DataType
530uuidType :: DataType
531−uuidType = mkNoRepType "Data.UUID.UUID"
531+uuidType = mkNoRepType "Data.UUID.Types.UUID"
532
532
533#if !(MIN_VERSION_base(4,2,0))
533#if !(MIN_VERSION_base(4,2,0))
534mkNoRepType :: String -> DataType
534mkNoRepType :: String -> DataType
Data/UUID/Builder.hs → uuid-types/Data/UUID/Types/Internal/Builder.hsrenamed+2−2
@@ -1,6 +1,6 @@
1{-# LANGUAGE TypeFamilies #-}
1{-# LANGUAGE TypeFamilies #-}
2
2
3−-- Module : Data.UUID.Builder
3+-- Module : Data.UUID.Types.Internal.Builder
4-- Copyright : (c) 2009 Mark Lentczner
4-- Copyright : (c) 2009 Mark Lentczner
5--
5--
6-- License : BSD-style
6-- License : BSD-style
@@ -28,7 +28,7 @@
28-- code was ungainly. Using this module makes the code very
28-- code was ungainly. Using this module makes the code very
29-- concise, and turns out to optimize to just as fast, or faster!
29-- concise, and turns out to optimize to just as fast, or faster!
30
30
31−module Data.UUID.Builder
31+module Data.UUID.Types.Internal.Builder
32 (ByteSource(..)
32 (ByteSource(..)
33 ,ByteSink
33 ,ByteSink
34 ,Takes1Byte
34 ,Takes1Byte
LICENSE → uuid-types/LICENSErenamed

The content is the same.

Setup.hs → uuid-types/Setup.hsrenamed

The content is the same.

tests/BenchByteString.hs → uuid-types/tests/BenchByteString.hsrenamed+1−1
@@ -9,7 +9,7 @@ import Test.QuickCheck
9import Criterion
9import Criterion
10import Criterion.Main
10import Criterion.Main
11
11
12−import Data.UUID
12+import Data.UUID.Types
13
13
14instance Arbitrary UUID where
14instance Arbitrary UUID where
15 arbitrary =
15 arbitrary =
tests/BenchUUID.hs → uuid-types/tests/BenchUUID.hsrenamed+1−23
@@ -6,19 +6,12 @@ import Control.DeepSeq
6import qualified Data.ByteString.Lazy.Internal as BL
6import qualified Data.ByteString.Lazy.Internal as BL
7#endif
7#endif
8import Criterion.Main
8import Criterion.Main
9−import Data.Char (ord)
10−import Data.IORef
11import Data.Maybe (fromJust)
9import Data.Maybe (fromJust)
12−import Data.Word
13import qualified Data.Set as Set
10import qualified Data.Set as Set
14import qualified Data.ByteString.Lazy as BL
11import qualified Data.ByteString.Lazy as BL
15−import qualified Data.UUID as U
12+import qualified Data.UUID.Types as U
16−import qualified Data.UUID.V1 as U
17−import qualified Data.UUID.V3 as U3
18−import qualified Data.UUID.V5 as U5
19import Foreign (alloca, peek, poke)
13import Foreign (alloca, peek, poke)
20import System.Random
14import System.Random
21−import System.Random.Mersenne.Pure64
22
15
23#if !(MIN_VERSION_bytestring(0,10,0))
16#if !(MIN_VERSION_bytestring(0,10,0))
24instance NFData BL.ByteString where
17instance NFData BL.ByteString where
@@ -31,7 +24,6 @@ main = do
31 u1 <- randomIO
24 u1 <- randomIO
32 let s1 = U.toString u1
25 let s1 = U.toString u1
33 b1 = U.toByteString u1
26 b1 = U.toByteString u1
34− n1 = (map (fromIntegral . ord) "http://www.haskell.org/") :: [Word8]
35 nil2 = fromJust $
27 nil2 = fromJust $
36 U.fromString "00000000-0000-0000-0000-000000000000"
28 U.fromString "00000000-0000-0000-0000-000000000000"
37 u2a = fromJust $ U.fromString "169a5a43-c051-4a16-98f4-08447ddd5dc0"
29 u2a = fromJust $ U.fromString "169a5a43-c051-4a16-98f4-08447ddd5dc0"
@@ -40,14 +32,6 @@ main = do
40 0x98, 0xf4, 0x08, 0x44, 0x7d, 0xdd, 0x5d, 0xc0]
32 0x98, 0xf4, 0x08, 0x44, 0x7d, 0xdd, 0x5d, 0xc0]
41 u3 = fromJust $ U.fromString "dea6f619-1038-438b-b4af-f1cdec1e6e23"
33 u3 = fromJust $ U.fromString "dea6f619-1038-438b-b4af-f1cdec1e6e23"
42
34
43− -- setup for random generation
44− randomState <- newPureMT >>= newIORef
45− let randomUUID = do
46− state <- readIORef randomState
47− let (uuid, state') = random state
48− writeIORef randomState state'
49− return uuid
50−
51 -- setup for Storable benchmark
35 -- setup for Storable benchmark
52 alloca $ \ uuidPtr -> do
36 alloca $ \ uuidPtr -> do
53
37
@@ -67,12 +51,6 @@ main = do
67 bench "toByteString" $ nf U.toByteString u1,
51 bench "toByteString" $ nf U.toByteString u1,
68 bench "fromByteString" $ nf U.fromByteString b1
52 bench "fromByteString" $ nf U.fromByteString b1
69 ],
53 ],
70− bgroup "generation" [
71− bench "V1" $ nfIO U.nextUUID,
72− bench "V4" $ nfIO (randomUUID :: IO U.UUID),
73− bench "V3" $ nf (U3.generateNamed U3.namespaceURL) n1,
74− bench "V5" $ nf (U5.generateNamed U5.namespaceURL) n1
75− ],
76 bench "set making" $ nf Set.fromList uuids,
54 bench "set making" $ nf Set.fromList uuids,
77
55
78 bgroup "storable" [
56 bgroup "storable" [
tests/TestUUID.hs → uuid-types/tests/TestUUID.hsrenamed+3−79
@@ -1,18 +1,11 @@
1{-# LANGUAGE ViewPatterns #-}
1{-# LANGUAGE ViewPatterns #-}
2−import Control.Monad (replicateM)
3−import Data.Bits
4import qualified Data.ByteString.Lazy as BL
2import qualified Data.ByteString.Lazy as BL
5import qualified Data.ByteString.Lazy.Char8 as BL8
3import qualified Data.ByteString.Lazy.Char8 as BL8
6import qualified Data.ByteString.Char8 as BC8
4import qualified Data.ByteString.Char8 as BC8
7import Data.Char (ord)
5import Data.Char (ord)
8import Data.Functor ((<$>))
6import Data.Functor ((<$>))
9−import Data.List (nub, (\\))
10−import Data.Maybe
11import Data.Word
7import Data.Word
12−import qualified Data.UUID as U
8+import qualified Data.UUID.Types as U
13−import qualified Data.UUID.V1 as U
14−import qualified Data.UUID.V3 as U3
15−import qualified Data.UUID.V5 as U5
16import Foreign (alloca, peek, poke)
9import Foreign (alloca, peek, poke)
17import System.IO.Unsafe (unsafePerformIO)
10import System.IO.Unsafe (unsafePerformIO)
18import qualified Test.HUnit as H
11import qualified Test.HUnit as H
@@ -23,14 +16,6 @@ import Test.Framework.Providers.HUnit (hUnitTestToTests)
23import Test.Framework.Providers.QuickCheck2 (testProperty)
16import Test.Framework.Providers.QuickCheck2 (testProperty)
24
17
25
18
26−isValidVersion :: Int -> U.UUID -> Bool
27−isValidVersion v u = lenOK && variantOK && versionOK
28− where bs = U.toByteString u
29− lenOK = BL.length bs == 16
30− variantOK = (BL.index bs 8) .&. 0xc0 == 0x80
31− versionOK = (BL.index bs 6) .&. 0xf0 == fromIntegral (v `shiftL` 4)
32−
33−
34instance Arbitrary U.UUID where
19instance Arbitrary U.UUID where
35 -- the UUID random instance ignores bounds
20 -- the UUID random instance ignores bounds
36 arbitrary = choose (U.nil, U.nil)
21 arbitrary = choose (U.nil, U.nil)
@@ -38,8 +23,7 @@ instance Arbitrary U.UUID where
38
23
39test_null :: H.Test
24test_null :: H.Test
40test_null = H.TestList [
25test_null = H.TestList [
41− "nil is null" ~: assertBool "" (U.null U.nil),
26+ "nil is null" ~: assertBool "" (U.null U.nil)
42− "namespaceDNS is not null" ~: assertBool "" (not $ U.null U3.namespaceDNS)
43 ]
27 ]
44
28
45test_nil :: H.Test
29test_nil :: H.Test
@@ -58,32 +42,6 @@ test_conv = H.TestList [
58 where b16 = BL.pack [1..16]
42 where b16 = BL.pack [1..16]
59 s16 = "01020304-0506-0708-090a-0b0c0d0e0f10"
43 s16 = "01020304-0506-0708-090a-0b0c0d0e0f10"
60
44
61−test_v1 :: [Maybe U.UUID] -> H.Test
62−test_v1 v1s = H.TestList [
63− "V1 unique" ~: nub (v1s \\ nub v1s) @?= [],
64− "V1 not null" ~: H.TestList $ map (testUUID (not . U.null)) v1s,
65− "V1 valid" ~: H.TestList $ map (testUUID (isValidVersion 1)) v1s
66− ]
67− where testUUID :: (U.UUID -> Bool) -> Maybe U.UUID -> H.Test
68− testUUID p u = maybe False p u ~? show u
69−
70−test_v3 :: H.Test
71−test_v3 = H.TestList [
72− "V3 computation" ~:
73− U3.generateNamed U3.namespaceDNS name @?= uV3
74− ]
75− where name = map (fromIntegral . ord) "www.widgets.com" :: [Word8]
76− uV3 = fromJust $ U.fromString "3d813cbb-47fb-32ba-91df-831e1593ac29"
77−
78−test_v5 :: H.Test
79−test_v5 = H.TestList [
80− "V5 computation" ~:
81− U5.generateNamed U5.namespaceDNS name @?= uV5
82− ]
83− where name = map (fromIntegral . ord) "www.widgets.com" :: [Word8]
84− uV5 = fromJust $ U.fromString "21f7f8de-8051-5b89-8680-0195ef798b6a"
85−
86−
87-- | Test fromByteString with a fixed-input.
45-- | Test fromByteString with a fixed-input.
88test_fromByteString :: H.Test
46test_fromByteString :: H.Test
89test_fromByteString =
47test_fromByteString =
@@ -131,31 +89,6 @@ prop_randomNotNull = testProperty "Random not null" randomNotNull
131 where randomNotNull :: U.UUID -> Bool
89 where randomNotNull :: U.UUID -> Bool
132 randomNotNull = not. U.null
90 randomNotNull = not. U.null
133
91
134−prop_randomsValid :: Test
135−prop_randomsValid = testProperty "Random valid" randomsValid
136− where randomsValid :: U.UUID -> Bool
137− randomsValid = isValidVersion 4
138−
139−prop_v3NotNull :: Test
140−prop_v3NotNull = testProperty "V3 not null" v3NotNull
141− where v3NotNull :: [Word8] -> Bool
142− v3NotNull = not . U.null . U3.generateNamed U3.namespaceDNS
143−
144−prop_v3Valid :: Test
145−prop_v3Valid = testProperty "V3 valid" v3Valid
146− where v3Valid :: [Word8] -> Bool
147− v3Valid = isValidVersion 3 . U3.generateNamed U3.namespaceDNS
148−
149−prop_v5NotNull :: Test
150−prop_v5NotNull = testProperty "V5 not null" v5NotNull
151− where v5NotNull :: [Word8] -> Bool
152− v5NotNull = not . U.null . U5.generateNamed U5.namespaceDNS
153−
154−prop_v5Valid :: Test
155−prop_v5Valid = testProperty "V5 valid" v5Valid
156− where v5Valid :: [Word8] -> Bool
157− v5Valid = isValidVersion 5 . U5.generateNamed U5.namespaceDNS
158−
159prop_readShowRoundTrip :: Test
92prop_readShowRoundTrip :: Test
160prop_readShowRoundTrip = testProperty "Read/Show round-trip" prop
93prop_readShowRoundTrip = testProperty "Read/Show round-trip" prop
161 where -- we're using 'Maybe UUID' to add a bit of
94 where -- we're using 'Maybe UUID' to add a bit of
@@ -210,16 +143,12 @@ prop_storableRoundTrip =
210
143
211main :: IO ()
144main :: IO ()
212main = do
145main = do
213− v1s <- replicateM 100 U.nextUUID
214 defaultMain $
146 defaultMain $
215 concat $
147 concat $
216 [ hUnitTestToTests $ H.TestList [
148 [ hUnitTestToTests $ H.TestList [
217 test_null,
149 test_null,
218 test_nil,
150 test_nil,
219 test_conv,
151 test_conv,
220− test_v1 v1s,
221− test_v3,
222− test_v5,
223 test_fromByteString,
152 test_fromByteString,
224 test_fromWords
153 test_fromWords
225 ]
154 ]
@@ -230,12 +159,7 @@ main = do
230 prop_stringLength,
159 prop_stringLength,
231 prop_byteStringLength,
160 prop_byteStringLength,
232 prop_randomsDiffer,
161 prop_randomsDiffer,
233− prop_randomNotNull,
162+ prop_randomNotNull
234− prop_randomsValid,
235− prop_v3NotNull,
236− prop_v3Valid,
237− prop_v5NotNull,
238− prop_v5Valid
239 ]
163 ]
240 , [ testProperty "fromASCIIBytes_fromString1" fromASCIIBytes_fromString1
164 , [ testProperty "fromASCIIBytes_fromString1" fromASCIIBytes_fromString1
241 , testProperty "fromASCIIBytes_fromString2" fromASCIIBytes_fromString2
165 , testProperty "fromASCIIBytes_fromString2" fromASCIIBytes_fromString2
tests/summarize-bench-results.pl → uuid-types/tests/summarize-bench-results.plrenamed

The content is the same.

uuid.cabal → uuid-types/uuid-types.cabalrenamed+14−26
@@ -1,5 +1,5 @@
1−Name: uuid
1+Name: uuid-types
2−Version: 1.3.8
2+Version: 1.0.0
3Copyright: (c) 2008-2014 Antoine Latter
3Copyright: (c) 2008-2014 Antoine Latter
4Author: Antoine Latter
4Author: Antoine Latter
5Maintainer: aslatter@gmail.com
5Maintainer: aslatter@gmail.com
@@ -11,11 +11,12 @@ Build-Type: Simple
11Cabal-Version: >= 1.8
11Cabal-Version: >= 1.8
12
12
13Description:
13Description:
14− This library is useful for creating, comparing, parsing and
15− printing Universally Unique Identifiers.
14+ This library contains type definitions for Universally Unique Identifiers
15+ and basic conversion functions.
16+
16 See <http://en.wikipedia.org/wiki/UUID> for the general idea.
17 See <http://en.wikipedia.org/wiki/UUID> for the general idea.
17
18
18−Synopsis: For creating, comparing, parsing and printing Universally Unique Identifiers
19+Synopsis: Type definitions for Universally Unique Identifiers
19
20
20Homepage: https://github.com/aslatter/uuid
21Homepage: https://github.com/aslatter/uuid
21Bug-Reports: https://github.com/aslatter/uuid/issues
22Bug-Reports: https://github.com/aslatter/uuid/issues
@@ -29,26 +30,15 @@ Library
29 Build-Depends: base >=3 && < 5,
30 Build-Depends: base >=3 && < 5,
30 binary >= 0.4 && < 0.8,
31 binary >= 0.4 && < 0.8,
31 bytestring >= 0.9 && < 1.1,
32 bytestring >= 0.9 && < 1.1,
32− cryptohash >= 0.7 && < 0.12,
33 deepseq >= 1.3 && < 1.5,
33 deepseq >= 1.3 && < 1.5,
34 hashable (>= 1.1.1.0 && < 1.2.0) || (>= 1.2.1 && < 1.3),
34 hashable (>= 1.1.1.0 && < 1.2.0) || (>= 1.2.1 && < 1.3),
35− network-info == 0.2.*,
36− random >= 1.0.1 && < 1.2,
35+ random >= 1.0.1 && < 1.2
37− time >= 1.1 && < 1.6
38
36
39 Exposed-Modules:
37 Exposed-Modules:
40− Data.UUID
38+ Data.UUID.Types
41− Data.UUID.Util
39+ -- Exposed for companion projects; *NOT* part of the official API:
42− Data.UUID.V1
43− Data.UUID.V3
44− Data.UUID.V4
45− Data.UUID.V5
46−
47− Other-Modules:
48− Data.UUID.Builder
40+ Data.UUID.Types.Internal.Builder
49− Data.UUID.Internal
41+ Data.UUID.Types.Internal
50− Data.UUID.Named
51− Data.Word.Util
52
42
53 Extensions: DeriveDataTypeable
43 Extensions: DeriveDataTypeable
54 Ghc-Options: -Wall
44 Ghc-Options: -Wall
@@ -64,11 +54,10 @@ Test-Suite testuuid
64 Extensions: DeriveDataTypeable
54 Extensions: DeriveDataTypeable
65 Ghc-Options: -Wall -fno-warn-orphans
55 Ghc-Options: -Wall -fno-warn-orphans
66 Build-Depends: base >= 3 && < 5,
56 Build-Depends: base >= 3 && < 5,
67− uuid,
57+ uuid-types,
68 bytestring >= 0.9 && < 1.1,
58 bytestring >= 0.9 && < 1.1,
69 HUnit >=1.2 && < 1.3,
59 HUnit >=1.2 && < 1.3,
70 QuickCheck >=2.4 && < 2.8,
60 QuickCheck >=2.4 && < 2.8,
71− random >= 1.0.1 && < 1.2,
72 test-framework == 0.8.*,
61 test-framework == 0.8.*,
73 test-framework-hunit == 0.3.*,
62 test-framework-hunit == 0.3.*,
74 test-framework-quickcheck2 == 0.3.*
63 test-framework-quickcheck2 == 0.3.*
@@ -80,12 +69,11 @@ benchmark benchmark
80 Extensions: DeriveDataTypeable, CPP
69 Extensions: DeriveDataTypeable, CPP
81 Ghc-Options: -Wall -fno-warn-orphans
70 Ghc-Options: -Wall -fno-warn-orphans
82 Build-depends: base == 4.*,
71 Build-depends: base == 4.*,
83− uuid,
72+ uuid-types,
84 bytestring >= 0.9 && < 1.1,
73 bytestring >= 0.9 && < 1.1,
85 containers >= 0.4 && < 0.6,
74 containers >= 0.4 && < 0.6,
86 criterion >= 0.4 && < 0.9,
75 criterion >= 0.4 && < 0.9,
87 deepseq >= 1.1 && < 1.4,
76 deepseq >= 1.1 && < 1.4,
88− mersenne-random-pure64,
89 random >= 1.0.1 && < 1.2
77 random >= 1.0.1 && < 1.2
90
78
91benchmark benchbytestring
79benchmark benchbytestring
@@ -94,7 +82,7 @@ benchmark benchbytestring
94 Main-Is: BenchByteString.hs
82 Main-Is: BenchByteString.hs
95 Ghc-Options: -threaded -rtsopts -Wall -O2 -fno-warn-orphans
83 Ghc-Options: -threaded -rtsopts -Wall -O2 -fno-warn-orphans
96 Build-Depends: base >= 4 && < 5
84 Build-Depends: base >= 4 && < 5
97− , uuid
85+ , uuid-types
98 , bytestring >= 0.10
86 , bytestring >= 0.10
99 , criterion >= 0.8
87 , criterion >= 0.8
100 , random >= 1.0
88 , random >= 1.0
CHANGES → uuid/CHANGESrenamed+5
@@ -1,3 +1,8 @@
1+1.3.9
2+
3+- Split definition of UUID data type into separate Cabal package to
4+ enable 3rd party libraries to avoid some of the larger dependencies.
5+
11.3.8
61.3.8
2
7
3- Allow building against newer deepseq.
8- Allow building against newer deepseq.
uuid/CONTRIBUTORSnew file+13
@@ -0,0 +1,13 @@
1+In order of appearance:
2+
3+Antoine Latter
4+Jason Dusek
5+Tim Newsham
6+Mark Lentczner
7+Neil Mitchell
8+Bas van Dijk
9+Sergei Trofimovich
10+davean
11+Francesco Mazzoli
12+Michael Snoyman
13+Bardur Arantsson
Data/UUID.hs → uuid/Data/UUID.hsrenamed+5−5
@@ -23,7 +23,6 @@ MAC address and current system time in "Data.UUID.V1".
23* For name-based generation of UUIDs using SHA-1 hashing see
23* For name-based generation of UUIDs using SHA-1 hashing see
24"Data.UUID.V5".
24"Data.UUID.V5".
25-}
25-}
26−
27module Data.UUID(UUID
26module Data.UUID(UUID
28 ,toString
27 ,toString
29 ,fromString
28 ,fromString
@@ -40,8 +39,9 @@ module Data.UUID(UUID
40 ) where
39 ) where
41
40
42import Prelude () -- we need to hide Prelude.null
41import Prelude () -- we need to hide Prelude.null
43−import Data.UUID.Internal
42+import Data.UUID.Types
44
43
45−-- Everything is really implemented in Data.UUID.Internal,
44+-- We use explicit re-exports of everything from Data.UUID.Types in
46−-- but I don't want to export the constructors out of the
45+-- preference to just re-exporting the whole module. This is to avoid
47−-- package.
46+-- unforeseen transitive API breakage if the Data.UUID.Types module
47+-- should change.
Data/UUID/Named.hs → uuid/Data/UUID/Named.hsrenamed+1−1
@@ -26,7 +26,7 @@ module Data.UUID.Named
26 ,namespaceX500
26 ,namespaceX500
27 ) where
27 ) where
28
28
29−import Data.UUID.Internal
29+import Data.UUID.Types.Internal
30
30
31import Control.Applicative ((<*>),(<$>))
31import Control.Applicative ((<*>),(<$>))
32import Data.Binary.Get (runGet, getWord32be)
32import Data.Binary.Get (runGet, getWord32be)
Data/UUID/Util.hs → uuid/Data/UUID/Util.hsrenamed+1−1
@@ -12,7 +12,7 @@ import Prelude hiding (null)
12import Data.Word
12import Data.Word
13import Data.Word.Util
13import Data.Word.Util
14import Data.Bits
14import Data.Bits
15−import Data.UUID.Internal
15+import Data.UUID.Types.Internal
16import Network.Info
16import Network.Info
17import Data.Int (Int64)
17import Data.Int (Int64)
18
18
Data/UUID/V1.hs → uuid/Data/UUID/V1.hsrenamed+2−2
@@ -39,8 +39,8 @@ import qualified System.Random as R
39
39
40import Network.Info
40import Network.Info
41
41
42−import Data.UUID.Builder
42+import Data.UUID.Types.Internal.Builder
43−import Data.UUID.Internal
43+import Data.UUID.Types.Internal
44
44
45-- | Returns a new UUID derived from the local hardware MAC
45-- | Returns a new UUID derived from the local hardware MAC
46-- address and the current system time.
46-- address and the current system time.
Data/UUID/V3.hs → uuid/Data/UUID/V3.hsrenamed+1−1
@@ -33,7 +33,7 @@ module Data.UUID.V3
33
33
34import Data.Word
34import Data.Word
35
35
36−import Data.UUID.Internal
36+import Data.UUID.Types.Internal
37import qualified Data.UUID.Named as Shared
37import qualified Data.UUID.Named as Shared
38import qualified Crypto.Hash.MD5 as MD5
38import qualified Crypto.Hash.MD5 as MD5
39
39
Data/UUID/V4.hs → uuid/Data/UUID/V4.hsrenamed

The content is the same.

Data/UUID/V5.hs → uuid/Data/UUID/V5.hsrenamed+1−1
@@ -28,7 +28,7 @@ module Data.UUID.V5
28
28
29import Data.Word
29import Data.Word
30
30
31−import Data.UUID.Internal
31+import Data.UUID.Types.Internal
32import qualified Data.UUID.Named as Shared
32import qualified Data.UUID.Named as Shared
33import qualified Crypto.Hash.SHA1 as SHA1
33import qualified Crypto.Hash.SHA1 as SHA1
34
34
Data/Word/Util.hs → uuid/Data/Word/Util.hsrenamed

The content is the same.

Demo.hs → uuid/Demo.hsrenamed

The content is the same.

uuid/LICENSEnew file+28
@@ -0,0 +1,28 @@
1+Copyright (c) 2008, Antoine Latter
2+
3+All rights reserved.
4+
5+Redistribution and use in source and binary forms, with or without
6+modification, are permitted provided that the following conditions are
7+met:
8+
9+ * Redistributions of source code must retain the above copyright
10+notice, this list of conditions and the following disclaimer.
11+ * Redistributions in binary form must reproduce the above copyright
12+notice, this list of conditions and the following disclaimer in the
13+documentation and/or other materials provided with the distribution.
14+ * The names of the authors may not be used to endorse or promote
15+products derived from this software without specific prior written
16+permission.
17+
18+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
uuid/Setup.hsnew file+4
@@ -0,0 +1,4 @@
1+import Distribution.Simple
2+main :: IO ()
3+main = defaultMain
4+
uuid/tests/BenchUUID.hsnew file+34
@@ -0,0 +1,34 @@
1+{-# LANGUAGE CPP #-}
2+
3+import Criterion.Main
4+import Data.Char (ord)
5+import Data.IORef
6+import Data.Word
7+import qualified Data.UUID as U
8+import qualified Data.UUID.V1 as U
9+import qualified Data.UUID.V3 as U3
10+import qualified Data.UUID.V5 as U5
11+import System.Random
12+import System.Random.Mersenne.Pure64
13+
14+main :: IO ()
15+main = do
16+ let n1 = (map (fromIntegral . ord) "http://www.haskell.org/") :: [Word8]
17+
18+ -- setup for random generation
19+ randomState <- newPureMT >>= newIORef
20+ let randomUUID = do
21+ state <- readIORef randomState
22+ let (uuid, state') = random state
23+ writeIORef randomState state'
24+ return uuid
25+
26+ -- benchmark UUID generation
27+ defaultMain [
28+ bgroup "generation" [
29+ bench "V1" $ nfIO U.nextUUID,
30+ bench "V4" $ nfIO (randomUUID :: IO U.UUID),
31+ bench "V3" $ nf (U3.generateNamed U3.namespaceURL) n1,
32+ bench "V5" $ nf (U5.generateNamed U5.namespaceURL) n1
33+ ]
34+ ]
uuid/tests/TestUUID.hsnew file+107
@@ -0,0 +1,107 @@
1+{-# LANGUAGE ViewPatterns #-}
2+import Control.Monad (replicateM)
3+import Data.Bits
4+import qualified Data.ByteString.Lazy as BL
5+import Data.Char (ord)
6+import Data.List (nub, (\\))
7+import Data.Maybe
8+import Data.Word
9+import qualified Data.UUID as U
10+import qualified Data.UUID.V1 as U
11+import qualified Data.UUID.V3 as U3
12+import qualified Data.UUID.V5 as U5
13+import qualified Test.HUnit as H
14+import Test.HUnit hiding (Test)
15+import Test.QuickCheck hiding ((.&.))
16+import Test.Framework (defaultMain, Test)
17+import Test.Framework.Providers.HUnit (hUnitTestToTests)
18+import Test.Framework.Providers.QuickCheck2 (testProperty)
19+
20+
21+isValidVersion :: Int -> U.UUID -> Bool
22+isValidVersion v u = lenOK && variantOK && versionOK
23+ where bs = U.toByteString u
24+ lenOK = BL.length bs == 16
25+ variantOK = (BL.index bs 8) .&. 0xc0 == 0x80
26+ versionOK = (BL.index bs 6) .&. 0xf0 == fromIntegral (v `shiftL` 4)
27+
28+
29+instance Arbitrary U.UUID where
30+ -- the UUID random instance ignores bounds
31+ arbitrary = choose (U.nil, U.nil)
32+
33+
34+test_null :: H.Test
35+test_null = H.TestList [
36+ "namespaceDNS is not null" ~: assertBool "" (not $ U.null U3.namespaceDNS)
37+ ]
38+
39+test_v1 :: [Maybe U.UUID] -> H.Test
40+test_v1 v1s = H.TestList [
41+ "V1 unique" ~: nub (v1s \\ nub v1s) @?= [],
42+ "V1 not null" ~: H.TestList $ map (testUUID (not . U.null)) v1s,
43+ "V1 valid" ~: H.TestList $ map (testUUID (isValidVersion 1)) v1s
44+ ]
45+ where testUUID :: (U.UUID -> Bool) -> Maybe U.UUID -> H.Test
46+ testUUID p u = maybe False p u ~? show u
47+
48+test_v3 :: H.Test
49+test_v3 = H.TestList [
50+ "V3 computation" ~:
51+ U3.generateNamed U3.namespaceDNS name @?= uV3
52+ ]
53+ where name = map (fromIntegral . ord) "www.widgets.com" :: [Word8]
54+ uV3 = fromJust $ U.fromString "3d813cbb-47fb-32ba-91df-831e1593ac29"
55+
56+test_v5 :: H.Test
57+test_v5 = H.TestList [
58+ "V5 computation" ~:
59+ U5.generateNamed U5.namespaceDNS name @?= uV5
60+ ]
61+ where name = map (fromIntegral . ord) "www.widgets.com" :: [Word8]
62+ uV5 = fromJust $ U.fromString "21f7f8de-8051-5b89-8680-0195ef798b6a"
63+
64+
65+prop_randomsValid :: Test
66+prop_randomsValid = testProperty "Random valid" randomsValid
67+ where randomsValid :: U.UUID -> Bool
68+ randomsValid = isValidVersion 4
69+
70+prop_v3NotNull :: Test
71+prop_v3NotNull = testProperty "V3 not null" v3NotNull
72+ where v3NotNull :: [Word8] -> Bool
73+ v3NotNull = not . U.null . U3.generateNamed U3.namespaceDNS
74+
75+prop_v3Valid :: Test
76+prop_v3Valid = testProperty "V3 valid" v3Valid
77+ where v3Valid :: [Word8] -> Bool
78+ v3Valid = isValidVersion 3 . U3.generateNamed U3.namespaceDNS
79+
80+prop_v5NotNull :: Test
81+prop_v5NotNull = testProperty "V5 not null" v5NotNull
82+ where v5NotNull :: [Word8] -> Bool
83+ v5NotNull = not . U.null . U5.generateNamed U5.namespaceDNS
84+
85+prop_v5Valid :: Test
86+prop_v5Valid = testProperty "V5 valid" v5Valid
87+ where v5Valid :: [Word8] -> Bool
88+ v5Valid = isValidVersion 5 . U5.generateNamed U5.namespaceDNS
89+
90+main :: IO ()
91+main = do
92+ v1s <- replicateM 100 U.nextUUID
93+ defaultMain $
94+ concat $
95+ [ hUnitTestToTests $ H.TestList [
96+ test_null,
97+ test_v1 v1s,
98+ test_v3,
99+ test_v5
100+ ]
101+ , [ prop_randomsValid,
102+ prop_v3NotNull,
103+ prop_v3Valid,
104+ prop_v5NotNull,
105+ prop_v5Valid
106+ ]
107+ ]
uuid/tests/summarize-bench-results.plnew file+14
@@ -0,0 +1,14 @@
1+#!/usr/bin/env perl
2+
3+
4+while(<>) {
5+ if (/^benchmarking (.*)$/) {
6+ $name = $1;
7+ }
8+ if (/^mean:\s*([\d.]*) (\w*),/) {
9+ $mean = 1 * $1;
10+ $units = $2;
11+
12+ printf "%-30s %10.2f %2s\n", $name, $mean, $units;
13+ }
14+}
uuid/uuid.cabalnew file+83
@@ -0,0 +1,83 @@
1+Name: uuid
2+Version: 1.3.9
3+Copyright: (c) 2008-2014 Antoine Latter
4+Author: Antoine Latter
5+Maintainer: aslatter@gmail.com
6+License: BSD3
7+License-file: LICENSE
8+
9+Category: Data
10+Build-Type: Simple
11+Cabal-Version: >= 1.8
12+
13+Description:
14+ This library is useful for creating, comparing, parsing and
15+ printing Universally Unique Identifiers.
16+ See <http://en.wikipedia.org/wiki/UUID> for the general idea.
17+
18+Synopsis: For creating, comparing, parsing and printing Universally Unique Identifiers
19+
20+Homepage: https://github.com/aslatter/uuid
21+Bug-Reports: https://github.com/aslatter/uuid/issues
22+
23+Extra-Source-Files:
24+ CHANGES
25+ CONTRIBUTORS
26+
27+
28+Library
29+ Build-Depends: base >=3 && < 5,
30+ binary >= 0.4 && < 0.8,
31+ bytestring >= 0.9 && < 1.1,
32+ cryptohash >= 0.7 && < 0.12,
33+ network-info == 0.2.*,
34+ random >= 1.0.1 && < 1.2,
35+ time >= 1.1 && < 1.6,
36+ uuid-types >= 1.0 && < 2
37+
38+ Exposed-Modules:
39+ Data.UUID
40+ Data.UUID.Util
41+ Data.UUID.V1
42+ Data.UUID.V3
43+ Data.UUID.V4
44+ Data.UUID.V5
45+
46+ Other-Modules:
47+ Data.UUID.Named
48+ Data.Word.Util
49+
50+ Extensions: DeriveDataTypeable
51+ Ghc-Options: -Wall
52+
53+source-repository head
54+ type: git
55+ location: https://github.com/aslatter/uuid.git
56+
57+Test-Suite testuuid
58+ Type: exitcode-stdio-1.0
59+ Main-is: TestUUID.hs
60+ Hs-source-dirs: tests
61+ Extensions: DeriveDataTypeable
62+ Ghc-Options: -Wall -fno-warn-orphans
63+ Build-Depends: base >= 3 && < 5,
64+ uuid,
65+ bytestring >= 0.9 && < 1.1,
66+ HUnit >=1.2 && < 1.3,
67+ QuickCheck >=2.4 && < 2.8,
68+ random >= 1.0.1 && < 1.2,
69+ test-framework == 0.8.*,
70+ test-framework-hunit == 0.3.*,
71+ test-framework-quickcheck2 == 0.3.*
72+
73+benchmark benchmark
74+ Type: exitcode-stdio-1.0
75+ Main-is: BenchUUID.hs
76+ Hs-source-dirs: tests
77+ Extensions: DeriveDataTypeable, CPP
78+ Ghc-Options: -Wall -fno-warn-orphans
79+ Build-depends: base == 4.*,
80+ uuid,
81+ criterion >= 0.4 && < 0.9,
82+ mersenne-random-pure64,
83+ random >= 1.0.1 && < 1.2