@@ -1,86 +1,88 @@
1−{-# LANGUAGE CPP #-}
2−{-# LANGUAGE DeriveDataTypeable #-}
3−{-# LANGUAGE TypeFamilies #-}
4−{-# LANGUAGE ViewPatterns #-}
5−{-# LANGUAGE Unsafe #-}
6−{-# LANGUAGE DeriveLift #-}
7−{-# LANGUAGE StandaloneDeriving #-}
1+{-# LANGUAGE DeriveDataTypeable, TypeFamilies, CPP #-}
82{-# OPTIONS_HADDOCK hide #-}
93
104-- |
115-- Module : Data.UUID.Types.Internal
12−-- Copyright : (c) 2017-2018 Herbert Valerio Riedel
13−-- (c) 2008-2009, 2012 Antoine Latter
6+-- Copyright : (c) 2008-2009, 2012 Antoine Latter
147-- (c) 2009 Mark Lentczner
158--
169-- License : BSD-style
1710--
18−-- Maintainer : hvr@gnu.org
11+-- Maintainer : aslatter@gmail.com
12+-- Stability : experimental
1913-- Portability : portable
2014
2115module Data.UUID.Types.Internal
22− ( UUID(..)
23− , null
24− , nil
25− , fromByteString
26− , toByteString
27− , fromString
28− , toString
29− , fromText
30− , toText
31− , fromWords
32− , toWords
33− , fromWords64
34− , toWords64
35− , toList
36− , buildFromBytes
37− , buildFromWords
38− , fromASCIIBytes
39− , toASCIIBytes
40− , fromLazyASCIIBytes
41− , toLazyASCIIBytes
42− , UnpackedUUID(..)
43− , pack
44− , unpack
16+ (UUID(..)
17+ ,null
18+ ,nil
19+ ,fromByteString
20+ ,toByteString
21+ ,fromString
22+ ,toString
23+ ,fromText
24+ ,toText
25+ ,fromWords
26+ ,toWords
27+ ,toList
28+ ,buildFromBytes
29+ ,buildFromWords
30+ ,fromASCIIBytes
31+ ,toASCIIBytes
32+ ,fromLazyASCIIBytes
33+ ,toLazyASCIIBytes
34+ ,UnpackedUUID(..)
35+ ,pack
36+ ,unpack
4537 ) where
4638
47−import Prelude hiding (null)
48−
49−import Control.DeepSeq (NFData (..))
50−import Control.Monad (guard, liftM2)
51−import Data.Bits
52−import Data.Char
53−import Data.Data
54−import Data.Hashable
55−import Data.List (elemIndices)
56−import Foreign.Ptr (Ptr)
57−
58−import Foreign.Storable
59−
60−import Data.Binary
61−import Data.Binary.Get
62−import Data.Binary.Put
63−import qualified Data.ByteString as B
64−import qualified Data.ByteString.Internal as BI
65−import qualified Data.ByteString.Lazy as BL
66−import qualified Data.ByteString.Unsafe as BU
67−import Data.Text (Text)
68−import qualified Data.Text.Encoding as T
69−
70−import Data.UUID.Types.Internal.Builder
71−
72−import System.Random (Random (..), uniform)
73−import System.Random.Stateful (Uniform (..), uniformWord64)
74−
75−import Language.Haskell.TH.Syntax (Lift)
76−
77−-- | Type representing <https://en.wikipedia.org/wiki/UUID Universally Unique Identifiers (UUID)> as specified in
78−-- <http://tools.ietf.org/html/rfc4122 RFC 4122>.
79−data UUID = UUID {-# UNPACK #-} !Word64 {-# UNPACK #-} !Word64
80− deriving (Eq, Ord)
39+import Prelude hiding (null)
40+
41+import Control.Applicative ((<*>))
42+import Control.DeepSeq (NFData(..))
43+import Control.Monad (liftM4, guard)
44+import Data.Functor ((<$>))
45+import Data.Char
46+import Data.Bits
47+import Data.Hashable
48+import Data.List (elemIndices)
49+import Foreign.Ptr (Ptr)
50+
51+#if MIN_VERSION_base(4,0,0)
52+import Data.Data
53+#else
54+import Data.Generics.Basics
55+#endif
56+
57+import Foreign.Storable
58+
59+import Data.Binary
60+import Data.Binary.Put
61+import Data.Binary.Get
62+import qualified Data.ByteString as B
63+import qualified Data.ByteString.Internal as BI
64+import qualified Data.ByteString.Lazy as BL
65+import qualified Data.ByteString.Unsafe as BU
66+import Data.Text (Text)
67+import qualified Data.Text as T
68+
69+import Data.UUID.Types.Internal.Builder
70+
71+import System.Random
72+
73+
74+-- |The UUID type. A 'Random' instance is provided which produces
75+-- version 4 UUIDs as specified in RFC 4122. The 'Storable' and
76+-- 'Binary' instances are compatible with RFC 4122, storing the fields
77+-- in network order as 16 bytes.
78+data UUID
79+ = UUID
80+ {-# UNPACK #-} !Word32
81+ {-# UNPACK #-} !Word32
82+ {-# UNPACK #-} !Word32
83+ {-# UNPACK #-} !Word32
84+ deriving (Eq, Ord, Typeable)
8185{-
82− Prior to uuid-types-1.0.4:
83− !Word32 !Word32 !Word32 !Word32
8486 Other representations that we tried are:
8587 Mimic V1 structure: !Word32 !Word16 !Word16 !Word16
8688 !Word8 !Word8 !Word8 !Word8 !Word8 !Word8
@@ -92,75 +94,40 @@ data UUID = UUID {-# UNPACK #-} !Word64 {-# UNPACK #-} !Word64
9294 None was as fast, overall, as the representation used here.
9395-}
9496
95−-- | Convert a 'UUID' into a sequence of 'Word32' values.
97+-- | Covert a 'UUID' into a sequence of 'Word32' values.
9698-- Useful for when you need to serialize a UUID and
9799-- neither 'Storable' nor 'Binary' are appropriate.
98−--
99−-- >>> toWords <$> fromString "550e8400-e29b-41d4-a716-446655440000"
100−-- Just (1427014656,3801825748,2803254374,1430519808)
101−--
102−-- See also 'toWords64'.
103−--
104−-- /Since: @uuid-1.2.2@/
105−--
106−-- @since 1.0.0
100+-- Introduced in version 1.2.2.
107101toWords :: UUID -> (Word32, Word32, Word32, Word32)
108−toWords (UUID w12 w34) = (w1, w2, w3, w4)
109− where
110− w1 = fromIntegral (w12 `unsafeShiftR` 32)
111− w2 = fromIntegral w12
112− w3 = fromIntegral (w34 `unsafeShiftR` 32)
113− w4 = fromIntegral w34
102+toWords (UUID w1 w2 w3 w4) = (w1, w2, w3, w4)
114103
115104-- | Create a 'UUID' from a sequence of 'Word32'. The
116−-- inverse of 'toWords'. Useful when you need a total
105+-- opposite of 'toWords'. Useful when you need a total
117106-- function for constructing 'UUID' values.
118−--
119−-- See also 'fromWords64'.
120−--
121−-- /Since: @uuid-1.2.2@/
122−--
123−-- @since 1.0.0
107+-- Introduced in version 1.2.2.
124108fromWords :: Word32 -> Word32 -> Word32 -> Word32 -> UUID
125−fromWords w1 w2 w3 w4 = UUID (w32to64 w1 w2) (w32to64 w3 w4)
126−
127−-- | Convert a 'UUID' into a pair of 'Word64's.
128−--
129−-- >>> toWords64 <$> fromString "550e8400-e29b-41d4-a716-446655440000"
130−-- Just (6128981282234515924,12039885860129472512)
131−--
132−-- See also 'toWords'.
133−--
134−-- @since 1.0.4
135−toWords64 :: UUID -> (Word64, Word64)
136−toWords64 (UUID w12 w34) = (w12,w34)
137−
138−-- | Create a 'UUID' from a pair of 'Word64's.
139−--
140−-- Inverse of 'toWords64'. See also 'fromWords'.
141−--
142−-- @since 1.0.4
143−fromWords64 :: Word64 -> Word64 -> UUID
144−fromWords64 = UUID
109+fromWords = UUID
145110
146111data UnpackedUUID =
147112 UnpackedUUID {
148− time_low :: Word32 -- 0-3
149− , time_mid :: Word16 -- 4-5
113+ time_low :: Word32 -- 0-3
114+ , time_mid :: Word16 -- 4-5
150115 , time_hi_and_version :: Word16 -- 6-7
151− , clock_seq_hi_res :: Word8 -- 8
152− , clock_seq_low :: Word8 -- 9
153− , node_0 :: Word8
154− , node_1 :: Word8
155− , node_2 :: Word8
156− , node_3 :: Word8
157− , node_4 :: Word8
158− , node_5 :: Word8
116+ , clock_seq_hi_res :: Word8 -- 8
117+ , clock_seq_low :: Word8 -- 9
118+ , node_0 :: Word8
119+ , node_1 :: Word8
120+ , node_2 :: Word8
121+ , node_3 :: Word8
122+ , node_4 :: Word8
123+ , node_5 :: Word8
159124 }
160125 deriving (Read, Show, Eq, Ord)
161126
162127unpack :: UUID -> UnpackedUUID
163−unpack (UUID w0 w1) = build /-/ w0 /-/ w1
128+unpack (UUID w0 w1 w2 w3) =
129+ build /-/ w0 /-/ w1 /-/ w2 /-/ w3
130+
164131 where
165132 build x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF =
166133 UnpackedUUID {
@@ -195,26 +162,23 @@ pack unpacked =
195162
196163-- |Build a Word32 from four Word8 values, presented in big-endian order
197164word :: Word8 -> Word8 -> Word8 -> Word8 -> Word32
198−word a b c d = (fromIntegral a `unsafeShiftL` 24)
199− .|. (fromIntegral b `unsafeShiftL` 16)
200− .|. (fromIntegral c `unsafeShiftL` 8)
201− .|. (fromIntegral d )
165+word a b c d = (fromIntegral a `shiftL` 24)
166+ .|. (fromIntegral b `shiftL` 16)
167+ .|. (fromIntegral c `shiftL` 8)
168+ .|. (fromIntegral d )
202169
203−-- |Extract a Word8 from a Word64. Bytes, high to low, are numbered from 7 to 0,
204−byte :: Int -> Word64 -> Word8
170+-- |Extract a Word8 from a Word32. Bytes, high to low, are numbered from 3 to 0,
171+byte :: Int -> Word32 -> Word8
205172byte i w = fromIntegral (w `shiftR` (i * 8))
206173
207174-- |Build a Word16 from two Word8 values, presented in big-endian order.
208175w8to16 :: Word8 -> Word8 -> Word16
209176w8to16 w0s w1s =
210− (w0 `unsafeShiftL` 8) .|. w1
177+ (w0 `shiftL` 8) .|. w1
211178 where
212179 w0 = fromIntegral w0s
213180 w1 = fromIntegral w1s
214181
215−-- | Construct 'Word64' from low/high 'Word32's
216−w32to64 :: Word32 -> Word32 -> Word64
217−w32to64 w0 w1 = (fromIntegral w0 `unsafeShiftL` 32) .|. (fromIntegral w1)
218182
219183-- |Make a UUID from sixteen Word8 values
220184makeFromBytes :: Word8 -> Word8 -> Word8 -> Word8
@@ -223,12 +187,16 @@ makeFromBytes :: Word8 -> Word8 -> Word8 -> Word8
223187 -> Word8 -> Word8 -> Word8 -> Word8
224188 -> UUID
225189makeFromBytes b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf
226− = fromWords w0 w1 w2 w3
190+ = UUID w0 w1 w2 w3
227191 where w0 = word b0 b1 b2 b3
228192 w1 = word b4 b5 b6 b7
229193 w2 = word b8 b9 ba bb
230194 w3 = word bc bd be bf
231195
196+-- |Make a UUID from four Word32 values
197+makeFromWords :: Word32 -> Word32 -> Word32 -> Word32 -> UUID
198+makeFromWords = UUID
199+
232200-- |A Builder for constructing a UUID of a given version.
233201buildFromBytes :: Word8
234202 -> Word8 -> Word8 -> Word8 -> Word8
@@ -241,20 +209,20 @@ buildFromBytes v b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf =
241209 where b6' = b6 .&. 0x0f .|. (v `shiftL` 4)
242210 b8' = b8 .&. 0x3f .|. 0x80
243211
244−-- |Build a UUID of a given version from 'Word32' values.
212+-- |Build a UUID of a given version from Word32 values.
245213buildFromWords :: Word8 -> Word32 -> Word32 -> Word32 -> Word32 -> UUID
246−buildFromWords v w0 w1 w2 w3 = fromWords w0 w1' w2' w3
214+buildFromWords v w0 w1 w2 w3 = makeFromWords w0 w1' w2' w3
247215 where w1' = w1 .&. 0xffff0fff .|. ((fromIntegral v) `shiftL` 12)
248216 w2' = w2 .&. 0x3fffffff .|. 0x80000000
249217
250218
251219-- |Return the bytes that make up the UUID
252220toList :: UUID -> [Word8]
253−toList (UUID w0 w1) =
254− [byte 7 w0, byte 6 w0, byte 5 w0, byte 4 w0,
255− byte 3 w0, byte 2 w0, byte 1 w0, byte 0 w0,
256− byte 7 w1, byte 6 w1, byte 5 w1, byte 4 w1,
257− byte 3 w1, byte 2 w1, byte 1 w1, byte 0 w1]
221+toList (UUID w0 w1 w2 w3) =
222+ [byte 3 w0, byte 2 w0, byte 1 w0, byte 0 w0,
223+ byte 3 w1, byte 2 w1, byte 1 w1, byte 0 w1,
224+ byte 3 w2, byte 2 w2, byte 1 w2, byte 0 w2,
225+ byte 3 w3, byte 2 w3, byte 1 w3, byte 0 w3]
258226
259227-- |Construct a UUID from a list of Word8. Returns Nothing if the list isn't
260228-- exactly sixteen bytes long
@@ -275,10 +243,10 @@ null = (== nil)
275243 -- null (UUID 0 0 0 0) = True
276244 -- null _ = False
277245
278−-- |The 'nil' UUID, as defined in <http://tools.ietf.org/html/rfc4122 RFC 4122>.
279−-- It is a UUID of all zeros. @'null' u@ /iff/ @'u' == 'nil'@.
246+-- |The nil UUID, as defined in RFC 4122.
247+-- It is a UUID of all zeros. @'null' u@ iff @'u' == 'nil'@.
280248nil :: UUID
281−nil = UUID 0 0
249+nil = UUID 0 0 0 0
282250
283251-- |Extract a UUID from a 'ByteString' in network byte order.
284252-- The argument must be 16 bytes long, otherwise 'Nothing' is returned.
@@ -286,8 +254,6 @@ fromByteString :: BL.ByteString -> Maybe UUID
286254fromByteString = fromList . BL.unpack
287255
288256-- |Encode a UUID into a 'ByteString' in network order.
289−--
290−-- This uses the same encoding as the 'Binary' instance.
291257toByteString :: UUID -> BL.ByteString
292258toByteString = BL.pack . toList
293259
@@ -295,8 +261,9 @@ toByteString = BL.pack . toList
295261-- The hyphens may not be omitted.
296262-- Example:
297263--
298−-- >>> fromString "c2cc10e1-57d6-4b6f-9899-38d972112d8c"
299−-- Just c2cc10e1-57d6-4b6f-9899-38d972112d8c
264+-- @
265+-- fromString \"c2cc10e1-57d6-4b6f-9899-38d972112d8c\"
266+-- @
300267--
301268-- Hex digits may be upper or lower-case.
302269fromString :: String -> Maybe UUID
@@ -311,7 +278,7 @@ fromString' s0 = do
311278 (w2, s3) <- hexWord s2
312279 (w3, s4) <- hexWord s3
313280 if s4 /= "" then Nothing
314− else Just $ fromWords w0 w1 w2 w3
281+ else Just $ UUID w0 w1 w2 w3
315282 where hexWord :: String -> Maybe (Word32, String)
316283 hexWord s = Just (0, s) >>= hexByte >>= hexByte
317284 >>= hexByte >>= hexByte
@@ -328,39 +295,30 @@ fromString' s0 = do
328295-- | Convert a UUID into a hypenated string using lower-case letters.
329296-- Example:
330297--
331−-- >>> toString <$> fromString "550e8400-e29b-41d4-a716-446655440000"
332−-- Just "550e8400-e29b-41d4-a716-446655440000"
333−--
334−--
298+-- @
299+-- toString \<$\> fromString \"550e8400-e29b-41d4-a716-446655440000\"
300+-- @
335301toString :: UUID -> String
336−toString uuid = hexw0 w0 $ hexw1 w1 ""
337− where hexw0 :: Word64 -> String -> String
338− hexw0 w s = hexn w 60 : hexn w 56 : hexn w 52 : hexn w 48
339− : hexn w 44 : hexn w 40 : hexn w 36 : hexn w 32
340− : '-' : hexn w 28 : hexn w 24 : hexn w 20 : hexn w 16
341− : '-' : hexn w 12 : hexn w 8 : hexn w 4 : hexn w 0
342− : s
343−
344− hexw1 :: Word64 -> String -> String
345− hexw1 w s = '-' : hexn w 60 : hexn w 56 : hexn w 52 : hexn w 48
346− : '-' : hexn w 44 : hexn w 40 : hexn w 36 : hexn w 32
347− : hexn w 28 : hexn w 24 : hexn w 20 : hexn w 16
348− : hexn w 12 : hexn w 8 : hexn w 4 : hexn w 0
349− : s
350−
351− hexn :: Word64 -> Int -> Char
352− hexn w r = intToDigit $ fromIntegral ((w `shiftR` r) .&. 0xf)
302+toString (UUID w0 w1 w2 w3) = hexw w0 $ hexw' w1 $ hexw' w2 $ hexw w3 ""
303+ where hexw :: Word32 -> String -> String
304+ hexw w s = hexn w 28 : hexn w 24 : hexn w 20 : hexn w 16
305+ : hexn w 12 : hexn w 8 : hexn w 4 : hexn w 0 : s
306+
307+ hexw' :: Word32 -> String -> String
308+ hexw' w s = '-' : hexn w 28 : hexn w 24 : hexn w 20 : hexn w 16
309+ : '-' : hexn w 12 : hexn w 8 : hexn w 4 : hexn w 0 : s
353310
354− (w0,w1) = toWords64 uuid
311+ hexn :: Word32 -> Int -> Char
312+ hexn w r = intToDigit $ fromIntegral ((w `shiftR` r) .&. 0xf)
355313
356314-- | If the passed in `Text` can be parsed as an ASCII representation of
357315-- a `UUID`, it will be. The hyphens may not be omitted.
358316fromText :: Text -> Maybe UUID
359−fromText = fromASCIIBytes . T.encodeUtf8
317+fromText = fromString . T.unpack
360318
361319-- | Convert a UUID into a hyphentated string using lower-case letters.
362320toText :: UUID -> Text
363−toText = T.decodeLatin1 . toASCIIBytes
321+toText = T.pack . toString
364322
365323-- | Convert a UUID into a hyphentated string using lower-case letters, packed
366324-- as ASCII bytes into `B.ByteString`.
@@ -455,30 +413,49 @@ fromASCIIBytes bs = do
455413-- | Similar to `toASCIIBytes` except we produce a lazy `BL.ByteString`.
456414toLazyASCIIBytes :: UUID -> BL.ByteString
457415toLazyASCIIBytes =
416+#if MIN_VERSION_bytestring(0,10,0)
458417 BL.fromStrict
418+#else
419+ BL.fromChunks . return
420+#endif
459421 . toASCIIBytes
460422
461423-- | Similar to `fromASCIIBytes` except parses from a lazy `BL.ByteString`.
462424fromLazyASCIIBytes :: BL.ByteString -> Maybe UUID
463425fromLazyASCIIBytes bs =
464− if BL.length bs == 36 then fromASCIIBytes (BL.toStrict bs) else Nothing
426+ if BL.length bs == 36 then fromASCIIBytes (
427+#if MIN_VERSION_bytestring(0,10,0)
428+ BL.toStrict bs
429+#else
430+ B.concat $ BL.toChunks bs
431+#endif
432+ ) else Nothing
465433
466434--
467435-- Class Instances
468436--
469437
470−-- | This 'Random' instance produces __insecure__ version 4 UUIDs as
471−-- specified in <http://tools.ietf.org/html/rfc4122 RFC 4122>.
472438instance Random UUID where
473− random = uniform
439+ random g = (fromGenNext w0 w1 w2 w3 w4, g4)
440+ where (w0, g0) = next g
441+ (w1, g1) = next g0
442+ (w2, g2) = next g1
443+ (w3, g3) = next g2
444+ (w4, g4) = next g3
474445 randomR _ = random -- range is ignored
475446
476−-- @since 1.0.4
477−instance Uniform UUID where
478− uniformM gen = do
479− w0 <- uniformWord64 gen
480− w1 <- uniformWord64 gen
481− pure $ buildFromBytes 4 /-/ w0 /-/ w1
447+-- |Build a UUID from the results of five calls to next on a StdGen.
448+-- While next on StdGet returns an Int, it doesn't provide 32 bits of
449+-- randomness. This code relies on at last 28 bits of randomness in the
450+-- and optimizes its use so as to make only five random values, not six.
451+fromGenNext :: Int -> Int -> Int -> Int -> Int -> UUID
452+fromGenNext w0 w1 w2 w3 w4 =
453+ buildFromBytes 4 /-/ (ThreeByte w0)
454+ /-/ (ThreeByte w1)
455+ /-/ w2 -- use all 4 bytes because we know the version
456+ -- field will "cover" the upper, non-random bits
457+ /-/ (ThreeByte w3)
458+ /-/ (ThreeByte w4)
482459
483460-- |A ByteSource to extract only three bytes from an Int, since next on StdGet
484461-- only returns 31 bits of randomness.
@@ -486,29 +463,24 @@ type instance ByteSink ThreeByte g = Takes3Bytes g
486463newtype ThreeByte = ThreeByte Int
487464instance ByteSource ThreeByte where
488465 f /-/ (ThreeByte w) = f b1 b2 b3
489− where b1 = fromIntegral (w `unsafeShiftR` 16)
490− b2 = fromIntegral (w `unsafeShiftR` 8)
466+ where b1 = fromIntegral (w `shiftR` 16)
467+ b2 = fromIntegral (w `shiftR` 8)
491468 b3 = fromIntegral w
492469
493470instance NFData UUID where
494− rnf = flip seq ()
471+ rnf = rnf . toWords
495472
496473instance Hashable UUID where
497− hash (toWords -> (w0,w1,w2,w3)) =
474+ hash (UUID w0 w1 w2 w3) =
498475 hash w0 `hashWithSalt` w1
499476 `hashWithSalt` w2
500477 `hashWithSalt` w3
501− hashWithSalt s (toWords -> (w0,w1,w2,w3)) =
478+ hashWithSalt s (UUID w0 w1 w2 w3) =
502479 s `hashWithSalt` w0
503480 `hashWithSalt` w1
504481 `hashWithSalt` w2
505482 `hashWithSalt` w3
506483
507−-- | Pretty prints a 'UUID' (without quotation marks). See also 'toString'.
508−--
509−-- >>> show nil
510−-- "00000000-0000-0000-0000-000000000000"
511−--
512484instance Show UUID where
513485 show = toString
514486
@@ -519,7 +491,7 @@ instance Read UUID where
519491 Nothing -> []
520492 Just u -> [(u,drop 36 noSpaces)]
521493
522−-- | This 'Storable' instance uses the memory layout as described in <http://tools.ietf.org/html/rfc4122 RFC 4122>, but in contrast to the 'Binary' instance, __the fields are stored in host byte order__.
494+
523495instance Storable UUID where
524496 sizeOf _ = 16
525497 alignment _ = 4
@@ -556,10 +528,10 @@ instance Storable UUID where
556528 pokeByteOff p (off+14) x9
557529 pokeByteOff p (off+15) x10
558530
559−-- | This 'Binary' instance is compatible with <http://tools.ietf.org/html/rfc4122 RFC 4122>, storing the fields in network order as 16 bytes.
560531instance Binary UUID where
561− put (UUID w0 w1) = putWord64be w0 >> putWord64be w1
562− get = liftM2 UUID getWord64be getWord64be
532+ put (UUID w0 w1 w2 w3) =
533+ putWord32be w0 >> putWord32be w1 >> putWord32be w2 >> putWord32be w3
534+ get = liftM4 UUID getWord32be getWord32be getWord32be getWord32be
563535
564536
565537-- My goal with this instance was to make it work just enough to do what
@@ -572,4 +544,7 @@ instance Data UUID where
572544uuidType :: DataType
573545uuidType = mkNoRepType "Data.UUID.Types.UUID"
574546
575−deriving instance Lift UUID
547+#if !(MIN_VERSION_base(4,2,0))
548+mkNoRepType :: String -> DataType
549+mkNoRepType = mkNorepType
550+#endif