on master help sign in
Expose `toWords64`/`fromWords64` de/constructors
583594fHerbert Valerio Riedel
uuid-types/CHANGES+6
@@ -1,3 +1,9 @@
1+1.0.4
2+
3+- Use more compact heap object representation
4+ which saves 16 bytes on 64bit platforms.
5+- Add toWords64/fromWords64
6+
11.0.3
71.0.3
2
8
3- Bump package dependencies
9- Bump package dependencies
uuid-types/Data/UUID/Types.hs+4−1
@@ -1,6 +1,7 @@
1{- |
1{- |
2Module : Data.UUID.Types
2Module : Data.UUID.Types
3+Copyright : (c) 2017-2018 Herbert Valerio Riedel
3−Copyright : (c) 2008,2012 Antoine Latter
4+ (c) 2008,2012 Antoine Latter
4
5
5License : BSD-style
6License : BSD-style
6
7
@@ -28,6 +29,8 @@ module Data.UUID.Types(UUID
28 ,fromByteString
29 ,fromByteString
29 ,toWords
30 ,toWords
30 ,fromWords
31 ,fromWords
32+ ,toWords64
33+ ,fromWords64
31 ,null
34 ,null
32 ,nil
35 ,nil
33 ) where
36 ) where
uuid-types/Data/UUID/Types/Internal.hs+32−4
@@ -27,6 +27,8 @@ module Data.UUID.Types.Internal
27 , toText
27 , toText
28 , fromWords
28 , fromWords
29 , toWords
29 , toWords
30+ , fromWords64
31+ , toWords64
30 , toList
32 , toList
31 , buildFromBytes
33 , buildFromBytes
32 , buildFromWords
34 , buildFromWords
@@ -94,10 +96,15 @@ data UUID = UUID {-# UNPACK #-} !Word64 {-# UNPACK #-} !Word64
94 None was as fast, overall, as the representation used here.
96 None was as fast, overall, as the representation used here.
95-}
97-}
96
98
97−-- | Covert a 'UUID' into a sequence of 'Word32' values.
99+-- | Convert a 'UUID' into a sequence of 'Word32' values.
98-- Useful for when you need to serialize a UUID and
100-- Useful for when you need to serialize a UUID and
99-- neither 'Storable' nor 'Binary' are appropriate.
101-- neither 'Storable' nor 'Binary' are appropriate.
100−-- Introduced in version 1.2.2.
102+--
103+-- See also 'toWords64'.
104+--
105+-- /Since: @uuid-1.2.2@/
106+--
107+-- @since 1.0.0
101toWords :: UUID -> (Word32, Word32, Word32, Word32)
108toWords :: UUID -> (Word32, Word32, Word32, Word32)
102toWords (UUID w12 w34) = (w1, w2, w3, w4)
109toWords (UUID w12 w34) = (w1, w2, w3, w4)
103 where
110 where
@@ -107,12 +114,33 @@ toWords (UUID w12 w34) = (w1, w2, w3, w4)
107 w4 = fromIntegral w34
114 w4 = fromIntegral w34
108
115
109-- | Create a 'UUID' from a sequence of 'Word32'. The
116-- | Create a 'UUID' from a sequence of 'Word32'. The
110−-- opposite of 'toWords'. Useful when you need a total
117+-- inverse of 'toWords'. Useful when you need a total
111-- function for constructing 'UUID' values.
118-- function for constructing 'UUID' values.
112−-- Introduced in version 1.2.2.
119+--
120+-- See also 'fromWords64'.
121+--
122+-- /Since: @uuid-1.2.2@/
123+--
124+-- @since 1.0.0
113fromWords :: Word32 -> Word32 -> Word32 -> Word32 -> UUID
125fromWords :: Word32 -> Word32 -> Word32 -> Word32 -> UUID
114fromWords w1 w2 w3 w4 = UUID (w32to64 w1 w2) (w32to64 w3 w4)
126fromWords w1 w2 w3 w4 = UUID (w32to64 w1 w2) (w32to64 w3 w4)
115
127
128+-- | Convert a 'UUID' into a pair of 'Word64's.
129+--
130+-- See also 'toWords'.
131+--
132+-- @since 1.0.4
133+toWords64 :: UUID -> (Word64, Word64)
134+toWords64 (UUID w12 w34) = (w12,w34)
135+
136+-- | Create a 'UUID' from a pair of 'Word64's.
137+--
138+-- Inverse of 'toWords64'. See also 'fromWords'.
139+--
140+-- @since 1.0.4
141+fromWords64 :: Word64 -> Word64 -> UUID
142+fromWords64 = UUID
143+
116data UnpackedUUID =
144data UnpackedUUID =
117 UnpackedUUID {
145 UnpackedUUID {
118 time_low :: Word32 -- 0-3
146 time_low :: Word32 -- 0-3