uuid-types 1.0.4 → 1.0.5
raw patch · 4 files changed
+48/−8 lines, 4 filesdep +template-haskelldep ~hashabledep ~text
Dependencies added: template-haskell
Dependency ranges changed: hashable, text
Files
- ChangeLog.md +4/−0
- src/Data/UUID/Types/Internal.hs +27/−0
- tests/TestUUID.hs +7/−0
- uuid-types.cabal +10/−8
ChangeLog.md view
@@ -1,3 +1,7 @@+## 1.0.5 (2021-05-03)++- Add (Template Haskell) `Lift UUID` instance+ ## 1.0.4.0 - Declare `Data.UUID.Types` module "`Trustworthy`" with respect to SafeHaskell.
src/Data/UUID/Types/Internal.hs view
@@ -5,6 +5,10 @@ #if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Unsafe #-} #endif+#if __GLASGOW_HASKELL__ >=800+{-# LANGUAGE DeriveLift #-}+{-# LANGUAGE StandaloneDeriving #-}+#endif {-# OPTIONS_HADDOCK hide #-} @@ -79,6 +83,12 @@ import System.Random (Random (..), next) #endif +#if __GLASGOW_HASKELL__ >=800+import Language.Haskell.TH.Syntax (Lift)+#else+import Language.Haskell.TH (appE, varE)+import Language.Haskell.TH.Syntax (Lift (..), mkNameG_v, Lit (IntegerL), Exp (LitE))+#endif -- | Type representing <https://en.wikipedia.org/wiki/UUID Universally Unique Identifiers (UUID)> as specified in -- <http://tools.ietf.org/html/rfc4122 RFC 4122>.@@ -618,4 +628,21 @@ unsafeShiftR = shiftR {-# INLINE unsafeShiftL #-} unsafeShiftL = shiftL+#endif++#if __GLASGOW_HASKELL__ >=800+deriving instance Lift UUID+#else+instance Lift UUID where+ lift (UUID w1 w2) = varE fromWords64Name `appE` liftW64 w1 `appE` liftW64 w2+ where+ fromWords64Name = mkNameG_v currentPackageKey "Data.UUID.Types.Internal" "fromWords64"+ liftW64 x = return (LitE (IntegerL (fromIntegral x)))++currentPackageKey :: String+#ifdef CURRENT_PACKAGE_KEY+currentPackageKey = CURRENT_PACKAGE_KEY+#else+currentPackageKey = "uuid-types-1.0.5"+#endif #endif
tests/TestUUID.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE ViewPatterns #-}+{-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -fno-warn-orphans #-} @@ -40,6 +41,11 @@ testCase "nil bytes" $ U.toByteString U.nil @?= BL.pack (replicate 16 0) ] +test_lift :: Test+test_lift = testCase "TH.Lift" $ do+ let uuid = U.fromWords64 123456789 987654321+ uuid @?= $( [| uuid |] )+ test_conv :: Test test_conv = testGroup "conversions" [ testCase "conv bytes to string" $@@ -176,6 +182,7 @@ [ [ test_null, test_nil,+ test_lift, test_conv, test_fromByteString, test_fromWords,
uuid-types.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.12 name: uuid-types-version: 1.0.4+version: 1.0.5 copyright: (c) 2017-2018 Herbert Valerio Riedel (c) 2008-2014 Antoine Latter@@ -45,13 +45,14 @@ library build-depends:- base >=4.5 && <5- , binary >=0.5.1.0 && <0.9- , bytestring >=0.9.2.1 && <0.12- , deepseq >=1.3.0.0 && <1.5- , hashable >=1.2.7.0 && <1.4- , random >=1.1 && <1.3- , text >=1.2.3.0 && <1.3+ base >=4.5 && <5+ , binary >=0.5.1.0 && <0.9+ , bytestring >=0.9.2.1 && <0.12+ , deepseq >=1.3.0.0 && <1.5+ , hashable >=1.2.7.0 && <1.4+ , random >=1.1 && <1.3+ , template-haskell >=2.7.0.0 && <2.18+ , text >=1.2.3.0 && <1.3 exposed-modules: Data.UUID.Types @@ -82,6 +83,7 @@ , binary , bytestring , uuid-types+ , template-haskell -- deps w/o inherited constraints build-depends: