on master help sign in
implements the 'null' function
616b00baslatter
Data/UUID.hs+1
@@ -22,6 +22,7 @@ module Data.UUID(UUID
22 ,null
22 ,null
23 ) where
23 ) where
24
24
25+import Prelude hiding (null)
25import Data.UUID.Internal
26import Data.UUID.Internal
26
27
27-- Everything is really implemented in Data.UUID.Internal,
28-- Everything is really implemented in Data.UUID.Internal,
Data/UUID/Internal.hs+13
@@ -12,7 +12,9 @@
12
12
13module Data.UUID.Internal
13module Data.UUID.Internal
14 (UUID(..)
14 (UUID(..)
15+ ,null
15 ,Node(..)
16 ,Node(..)
17+ ,nullNode
16 ,nodeToList
18 ,nodeToList
17 ,listToNode
19 ,listToNode
18 ,fromString
20 ,fromString
@@ -22,6 +24,9 @@ module Data.UUID.Internal
22 ,reserved
24 ,reserved
23 ) where
25 ) where
24
26
27+import Prelude hiding (null)
28+import qualified Prelude
29+
25import Data.Word
30import Data.Word
26import Data.Char
31import Data.Char
27import Data.Maybe
32import Data.Maybe
@@ -66,6 +71,11 @@ data UUID = UUID
66 ,uuid_node :: SLOT(Node)
71 ,uuid_node :: SLOT(Node)
67 } deriving (Eq, Ord, Typeable)
72 } deriving (Eq, Ord, Typeable)
68
73
74+-- |Returns true if the passed-in UUID is the null UUID.
75+null :: UUID -> Bool
76+null (UUID 0 0 0 0 0 node) | nullNode node = True
77+null _ = False
78+
69instance Random UUID where
79instance Random UUID where
70 random g = let (timeLow, g1) = randomBoundedIntegral g
80 random g = let (timeLow, g1) = randomBoundedIntegral g
71 (timeMid, g2) = randomBoundedIntegral g1
81 (timeMid, g2) = randomBoundedIntegral g1
@@ -110,6 +120,9 @@ instance Random Node where
110 in (Node w1 w2 w3 w4 w5 w6, g6)
120 in (Node w1 w2 w3 w4 w5 w6, g6)
111 randomR _ = random -- neglect range
121 randomR _ = random -- neglect range
112
122
123+nullNode :: Node -> Bool
124+nullNode (Node 0 0 0 0 0 0) = True
125+nullNode _ = False
113
126
114nodeToList :: Node -> [Word8]
127nodeToList :: Node -> [Word8]
115nodeToList (Node w1 w2 w3 w4 w5 w6) = [w1, w2, w3, w4, w5, w6]
128nodeToList (Node w1 w2 w3 w4 w5 w6) = [w1, w2, w3, w4, w5, w6]