on master help sign in
cleanup before release
8b12565aslatter
Data/UUID.hs+6−10
@@ -12,22 +12,18 @@
12-- This library is useful for comparing, parsing and
12-- This library is useful for comparing, parsing and
13-- printing Universally Unique Identifiers.
13-- printing Universally Unique Identifiers.
14-- See <http://en.wikipedia.org/wiki/UUID> for the general idea.
14-- See <http://en.wikipedia.org/wiki/UUID> for the general idea.
15+--
16+-- For generating UUIDs, check out 'Data.UUID.V1', 'Data.UUID.V5' and
17+-- 'System.Random'.
15
18
16module Data.UUID(UUID
19module Data.UUID(UUID
17− ,module Data.UUID.V1
18− ,module Data.UUID.V5
19 ,toString
20 ,toString
20 ,fromString
21 ,fromString
21 ,null
22 ,null
22 ) where
23 ) where
23
24
24import Data.UUID.Internal
25import Data.UUID.Internal
25−import Data.UUID.V1
26−import Data.UUID.V5
27−
28−import Prelude hiding (null)
29
26
30−-- |Returns 'True' if the passed-in 'UUID' is the null UUID.
27+-- Everything is really implemented in Data.UUID.Internal,
31−null :: UUID -> Bool
28+-- but I don't want to export the constructors out of the
32−null = (== nullUuid)
29+-- package.
33− where nullUuid = UUID 0 0 0 0 0 $ Node 0 0 0 0 0 0
Data/UUID/Internal.hs+9−7
@@ -257,13 +257,14 @@ toString (UUID tl tm th ch cl n) = printf "%08x-%04x-%04x-%02x%02x-%s" tl tm th
257
257
258
258
259-- remove all occurances of the input element in the inpt list.
259-- remove all occurances of the input element in the inpt list.
260−-- non of the sub-lists are empty.
260+-- none of the sub-lists are empty.
261splitList :: Eq a => a -> [a] -> [[a]]
261splitList :: Eq a => a -> [a] -> [[a]]
262splitList c xs = let ys = dropWhile (== c) xs
262splitList c xs = let ys = dropWhile (== c) xs
263 in case span (/= c) ys of
263 in case span (/= c) ys of
264 ([],_) -> []
264 ([],_) -> []
265 (sub,rest) -> sub : splitList c rest
265 (sub,rest) -> sub : splitList c rest
266
266
267+-- the passed-in predicate signals when to stop unfolding
267unfoldUntil :: (b -> Bool) -> (b -> (a, b)) -> b -> [a]
268unfoldUntil :: (b -> Bool) -> (b -> (a, b)) -> b -> [a]
268unfoldUntil p f n = unfoldr g n
269unfoldUntil p f n = unfoldr g n
269 where g m | p m = Nothing
270 where g m | p m = Nothing
@@ -274,10 +275,11 @@ unfoldUntil p f n = unfoldr g n
274-- this will work, though
275-- this will work, though
275
276
276randomBoundedIntegral :: (RandomGen g, Bounded a, Integral a) => g -> (a, g)
277randomBoundedIntegral :: (RandomGen g, Bounded a, Integral a) => g -> (a, g)
278+randomBoundedIntegral g =
277−randomBoundedIntegral g = let (n, g1) = randomR (fromIntegral l, fromIntegral u) g
279+ let (n, g1) = randomR (fromIntegral l, fromIntegral u) g
278− _ = n :: Integer
280+ _ = n :: Integer
279− retVal = fromIntegral n `asTypeOf` (l `asTypeOf` u)
281+ retVal = fromIntegral n `asTypeOf` (l `asTypeOf` u)
280− u = maxBound
282+ u = maxBound
281− l = minBound
283+ l = minBound
282− in (retVal, g1)
284+ in (retVal, g1)
283
285
uuid.cabal+4−6
@@ -11,12 +11,6 @@ Build-Type: Simple
11Cabal-Version: >= 1.2
11Cabal-Version: >= 1.2
12
12
13Description:
13Description:
14− Haskell bindings to libuuid.
15− .
16− The library libuuid is available as a part of e2fsprogs:
17− <http://e2fsprogs.sourceforge.net/>.
18− .
19− .
20 This library is useful for creating, comparing, parsing and
14 This library is useful for creating, comparing, parsing and
21 printing Universally Unique Identifiers.
15 printing Universally Unique Identifiers.
22 See <http://en.wikipedia.org/wiki/UUID> for the general idea.
16 See <http://en.wikipedia.org/wiki/UUID> for the general idea.
@@ -31,7 +25,11 @@ Library
31
25
32 Exposed-Modules:
26 Exposed-Modules:
33 Data.UUID
27 Data.UUID
28+ Data.UUID.V1
34 Data.UUID.V5
29 Data.UUID.V5
35
30
31+ Other-Modules:
32+ Data.UUID.Internal
33+
36 Extensions: DeriveDataTypeable
34 Extensions: DeriveDataTypeable
37
35