on master help sign in
Add functions fromWords/toWords, bump version
commitefa8fa809fc456d6c43cf5dccf688cbf055f0ae1 authorAntoine Latter <aslatter@gmail.com> dateThu 28 Apr 2011, 02:18 (16 years ago) parent3f28637
3 files changed+16−2
Data/UUID.hs+2 Data/UUID/Internal.hs+12 uuid.cabal+2−2
Data/UUID.hs+2
@@ -22,6 +22,8 @@ module Data.UUID(UUID
2222 ,fromString
2323 ,toByteString
2424 ,fromByteString
25+ ,toWords
26+ ,fromWords
2527 ,null
2628 ,nil
2729 ) where
Data/UUID/Internal.hs+12
@@ -19,6 +19,8 @@ module Data.UUID.Internal
1919 ,toByteString
2020 ,fromString
2121 ,toString
22+ ,fromWords
23+ ,toWords
2224 ,buildFromBytes
2325 ,buildFromWords
2426 ) where
@@ -68,6 +70,16 @@ data UUID = UUID !Word32 !Word32 !Word32 !Word32
6870 None was as fast, overall, as the representation used here.
6971-}
7072
73+-- | Covert a 'UUID' into a sequence of 'Word32' values.
74+-- Usefull for when you need to serialize a UUID and
75+-- neither 'Storable' nor 'Binary' are appropriate.
76+toWords :: UUID -> (Word32, Word32, Word32, Word32)
77+toWords (UUID w1 w2 w3 w4) = (w1, w2, w3, w4)
78+
79+-- | Create a 'UUID' from a sequence of 'Word32'. The
80+-- opposite of 'toWords'.
81+fromWords :: Word32 -> Word32 -> Word32 -> Word32 -> UUID
82+fromWords = UUID
7183
7284--
7385-- UTILITIES
uuid.cabal+2−2
@@ -1,6 +1,6 @@
11Name: uuid
2−Version: 1.2.1
3−Copyright: (c) 2008-2010 Antoine Latter
2+Version: 1.2.2
3+Copyright: (c) 2008-2011 Antoine Latter
44Author: Antoine Latter
55Maintainer: aslatter@gmail.com
66License: BSD3