packages feed

mmzk-typeid 0.7.0.1 → 0.7.0.2

raw patch · 7 files changed

+42/−19 lines, 7 filesdep ~basedep ~containersdep ~hashable

Dependency ranges changed: base, containers, hashable, time

Files

CHANGELOG.md view
@@ -1,6 +1,15 @@ # Revision history for mmzk-typeid  +## 0.7.0.2 -- 2025-04-22++* Fix a Haddock error on `ValidPrefix` related to conditional compilation.++* Add more tests.++* CI test on the latest GHC version.++ ## 0.7.0.1 -- 2024-10-10  * Add `Generic` derivation to `TypeID'`, `KindID'`, and `UUIDVersion`.
README.md view
@@ -65,14 +65,14 @@  ### TypeID with other UUID Versions -We also support TypeID using some other versions of `UUID`, including v1 and v4, which loses the monoticity property. To use it, simply import `Data.TypeID.V4` instead of `Data.TypeID`. The following is an example using v4:+We also support TypeID using some other versions of `UUID`, including v1, v4 and v5, which loses the monoticity property. To use it, simply import `Data.TypeID.V4` instead of `Data.TypeID`. The following is an example using v4:  ```Haskell {-# LANGUAGE OverloadedStrings #-}  import           Control.Exception-import           Data.TypeIDV4 (TypeIDV4)-import qualified Data.TypeIDV4 as TID+import           Data.TypeID.V4 (TypeIDV4)+import qualified Data.TypeID.V4 as TID  main :: IO () main = do
mmzk-typeid.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               mmzk-typeid-version:            0.7.0.1+version:            0.7.0.2  synopsis:           A TypeID and UUIDv7 implementation for Haskell description:@@ -100,12 +100,12 @@         aeson >=2.1 && <3,         array ^>=0.5,         binary >=0.8.5 && <0.9,-        bytestring >=0.11 && < 0.13,+        bytestring >=0.11 && <0.13,         entropy ^>=0.4,-        hashable ^>=1.4,+        hashable >=1.4 && <2,         random ^>=1.2,         text ^>=2.1,-        time >=1.11 && <1.13,+        time >=1.11 && <2,         uuid ^>=1.3,         uuid-types ^>=1.0,     ghc-options:@@ -165,12 +165,12 @@         TypeFamilies         TypeOperators     build-depends:-        base,+        base >=4.16 && <5,         aeson,         array,         binary,         bytestring,-        containers ^>=0.6,+        containers >=0.6 && <1,         entropy,         hashable,         hint ^>=0.9,
src/Data/KindID/Class.hs view
@@ -65,17 +65,19 @@ instance ToPrefix (s :: Symbol) where   type PrefixSymbol s = s +#ifndef __HADDOCK_VERSION__ -- | A constraint for valid prefix 'Symbol's. ---#ifndef __HADDOCK_VERSION__ type ValidPrefix prefix = ( KnownSymbol prefix                           , LengthLT64C prefix                           , IsLUSymbolC prefix ) #else+-- | A constraint for valid prefix 'Symbol's.+-- -- Note that this is __NOT__ the actual definition! Its true definition is -- hidden here in the documentation as it uses internal type-level helpers that--- we do not expose and make no guarantee on their In practice, any prefix with--- this constraint is a valid prefix for a 'Data.KindID.KindID'.+-- we do not expose and make no guarantee on their stability. In practice, any+-- prefix with this constraint is a valid prefix for a 'Data.KindID.KindID'. type ValidPrefix prefix = KnownSymbol prefix #endif 
src/Data/TypeID.hs view
@@ -4,7 +4,7 @@ -- Maintainer  : mmzk1526@outlook.com -- Portability : GHC ----- An implementation of the TypeID specification:+-- An implementation of the 'TypeID' specification: -- https://github.com/jetpack-io/typeid. -- -- It is a re-export of "Data.TypeID.V7".
src/Data/TypeID/Internal.hs view
@@ -436,7 +436,7 @@ genTypeIDV5 :: MonadIO m => Text -> UUID -> [Word8] -> m (TypeID' 'V5) genTypeIDV5 prefix ns obj = case checkPrefix prefix of   Nothing  -> pure $ unsafeGenTypeIDV5 prefix ns obj-  Just err -> throw err+  Just err -> liftIO $ throwIO err {-# INLINE genTypeIDV5 #-}  -- | Obtain a 'TypeID'' from a prefix and a 'UUID'.@@ -675,6 +675,13 @@                               . unsafeDecodeUUID $ suffix {-# INLINE unsafeParseByteString #-} +-- | A helper for generating 'UUID'v1.+nextUUID :: IO UUID+nextUUID = V1.nextUUID >>= maybe nextUUID pure+{-# INLINE nextUUID #-}++-- Helpers+ concat5BitInts :: [Word8] -> [Word8] concat5BitInts   = reverse . toBytes@@ -692,11 +699,6 @@     toBytes 0 = []     toBytes x = fromIntegral (x .&. 0x1F) : toBytes (x `shiftR` 5) {-# INLINE separate5BitInts #-}---- | A helper for generating 'UUID'v1.-nextUUID :: IO UUID-nextUUID = V1.nextUUID >>= maybe nextUUID pure-{-# INLINE nextUUID #-}  spanEnd :: (a -> Bool) -> [a] -> ([a], [a]) spanEnd p = bimap reverse reverse . span p . reverse
test/invalid.json view
@@ -93,5 +93,15 @@     "name": "prefix-underscore-end",     "typeid": "prefix__00000000000000000000000000",     "description": "The prefix can't end with an underscore"+  },+  {+    "name": "empty",+    "typeid": "",+    "description": "The empty string is not a valid typeid"+  },+  {+    "name": "prefix-empty",+    "typeid": "prefix_",+    "description": "The suffix can't be the empty string"   } ]