on master help sign in
implements the 'null' function
commit616b00bfb82d36047b879d8f6d11c30f832e6fee authoraslatter <aslatter@gmail.com> dateMon 25 May 2009, 20:52 (17 years ago) parenta093936
2 files changed+14
Data/UUID.hs+1 Data/UUID/Internal.hs+13
Data/UUID.hs+1
@@ -22,6 +22,7 @@ module Data.UUID(UUID
2222 ,null
2323 ) where
2424
25+import Prelude hiding (null)
2526import Data.UUID.Internal
2627
2728-- Everything is really implemented in Data.UUID.Internal,
Data/UUID/Internal.hs+13
@@ -12,7 +12,9 @@
1212
1313module Data.UUID.Internal
1414 (UUID(..)
15+ ,null
1516 ,Node(..)
17+ ,nullNode
1618 ,nodeToList
1719 ,listToNode
1820 ,fromString
@@ -22,6 +24,9 @@ module Data.UUID.Internal
2224 ,reserved
2325 ) where
2426
27+import Prelude hiding (null)
28+import qualified Prelude
29+
2530import Data.Word
2631import Data.Char
2732import Data.Maybe
@@ -66,6 +71,11 @@ data UUID = UUID
6671 ,uuid_node :: SLOT(Node)
6772 } deriving (Eq, Ord, Typeable)
6873
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+
6979instance Random UUID where
7080 random g = let (timeLow, g1) = randomBoundedIntegral g
7181 (timeMid, g2) = randomBoundedIntegral g1
@@ -110,6 +120,9 @@ instance Random Node where
110120 in (Node w1 w2 w3 w4 w5 w6, g6)
111121 randomR _ = random -- neglect range
112122
123+nullNode :: Node -> Bool
124+nullNode (Node 0 0 0 0 0 0) = True
125+nullNode _ = False
113126
114127nodeToList :: Node -> [Word8]
115128nodeToList (Node w1 w2 w3 w4 w5 w6) = [w1, w2, w3, w4, w5, w6]