on master help sign in
cleanup before release
commit8b12565117f76bde95bf4e1441af78fa21a76c59 authoraslatter <aslatter@gmail.com> dateFri 10 Oct 2008, 02:54 (18 years ago) parent7589b09
3 files changed+19−23
Data/UUID.hs+6−10 Data/UUID/Internal.hs+9−7 uuid.cabal+4−6
Data/UUID.hs+6−10
@@ -12,22 +12,18 @@
1212-- This library is useful for comparing, parsing and
1313-- printing Universally Unique Identifiers.
1414-- 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'.
1518
1619module Data.UUID(UUID
17− ,module Data.UUID.V1
18− ,module Data.UUID.V5
1920 ,toString
2021 ,fromString
2122 ,null
2223 ) where
2324
2425import Data.UUID.Internal
25−import Data.UUID.V1
26−import Data.UUID.V5
27−
28−import Prelude hiding (null)
2926
30−-- |Returns 'True' if the passed-in 'UUID' is the null UUID.
31−null :: UUID -> Bool
32−null = (== nullUuid)
33− where nullUuid = UUID 0 0 0 0 0 $ Node 0 0 0 0 0 0
27+-- Everything is really implemented in Data.UUID.Internal,
28+-- but I don't want to export the constructors out of the
29+-- package.
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
257257
258258
259259-- 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.
261261splitList :: Eq a => a -> [a] -> [[a]]
262262splitList c xs = let ys = dropWhile (== c) xs
263263 in case span (/= c) ys of
264264 ([],_) -> []
265265 (sub,rest) -> sub : splitList c rest
266266
267+-- the passed-in predicate signals when to stop unfolding
267268unfoldUntil :: (b -> Bool) -> (b -> (a, b)) -> b -> [a]
268269unfoldUntil p f n = unfoldr g n
269270 where g m | p m = Nothing
@@ -274,10 +275,11 @@ unfoldUntil p f n = unfoldr g n
274275-- this will work, though
275276
276277randomBoundedIntegral :: (RandomGen g, Bounded a, Integral a) => g -> (a, g)
277−randomBoundedIntegral g = let (n, g1) = randomR (fromIntegral l, fromIntegral u) g
278− _ = n :: Integer
279− retVal = fromIntegral n `asTypeOf` (l `asTypeOf` u)
280− u = maxBound
281− l = minBound
282− in (retVal, g1)
278+randomBoundedIntegral g =
279+ let (n, g1) = randomR (fromIntegral l, fromIntegral u) g
280+ _ = n :: Integer
281+ retVal = fromIntegral n `asTypeOf` (l `asTypeOf` u)
282+ u = maxBound
283+ l = minBound
284+ in (retVal, g1)
283285
uuid.cabal+4−6
@@ -11,12 +11,6 @@ Build-Type: Simple
1111Cabal-Version: >= 1.2
1212
1313Description:
14− Haskell bindings to libuuid.
15− .
16− The library libuuid is available as a part of e2fsprogs:
17− <http://e2fsprogs.sourceforge.net/>.
18− .
19− .
2014 This library is useful for creating, comparing, parsing and
2115 printing Universally Unique Identifiers.
2216 See <http://en.wikipedia.org/wiki/UUID> for the general idea.
@@ -31,7 +25,11 @@ Library
3125
3226 Exposed-Modules:
3327 Data.UUID
28+ Data.UUID.V1
3429 Data.UUID.V5
3530
31+ Other-Modules:
32+ Data.UUID.Internal
33+
3634 Extensions: DeriveDataTypeable
3735