diff --git a/CHANGELOG.md b/CHANGELOG.md index 028ad7b..efd9b32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Revision history for mmzk-typeid -## 0.6.0.2 -- Unreleased +## 0.6.0.0 -- Unreleased * Update implementation to conform with specification v0.3.0. * Allow `TypeID` prefix to contain underscores. diff --git a/mmzk-typeid.cabal b/mmzk-typeid.cabal index bcf0f32..a7e1b7c 100644 --- a/mmzk-typeid.cabal +++ b/mmzk-typeid.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: mmzk-typeid -version: 0.5.0.2 +version: 0.6.0.0 synopsis: A TypeID implementation for Haskell description: @@ -98,7 +98,7 @@ library aeson >=2.1 && <3, array ^>=0.5, binary >=0.8.5 && <0.9, - bytestring ^>= 0.11, + bytestring ^>=0.11, entropy ^>=0.4, hashable ^>=1.4, random ^>=1.2, diff --git a/src/Data/TypeID/Internal.hs b/src/Data/TypeID/Internal.hs index f33ec3d..997ea29 100644 --- a/src/Data/TypeID/Internal.hs +++ b/src/Data/TypeID/Internal.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE UndecidableInstances #-} -- | -- Module : Data.TypeID.Internal -- License : MIT @@ -121,9 +120,9 @@ instance Binary (TypeID' version) where uuid <- get len <- getWord8 encodedPrefix <- separate5BitInts <$> replicateM (fromIntegral len) getWord8 - when (length encodedPrefix > 63) $ fail "Binary: Prefix too long" - when (any (liftM2 (&&) (< 1) (> 26)) encodedPrefix) - (fail "Binary: Invalid prefix") + when (length encodedPrefix > 63) do fail "Binary: Prefix too long" + when (any (liftM2 (&&) (< 1) (> 26)) encodedPrefix) do + fail "Binary: Invalid prefix" let back 27 = 95 back a = a + 96 pure $ TypeID' (decodeUtf8 . BS.pack $ fmap back encodedPrefix) uuid @@ -146,8 +145,8 @@ instance Storable (TypeID' version) where encodedPrefix <- separate5BitInts <$> forM [1..len] \ix -> peekByteOff @Word8 ptr (16 + ix) when (length encodedPrefix > 63) $ fail "Storable: Prefix too long" - when (any (liftM2 (&&) (< 1) (> 26)) encodedPrefix) - (fail "Storable: Invalid prefix") + when (any (liftM2 (&&) (< 1) (> 26)) encodedPrefix) do + fail "Storable: Invalid prefix" let back 27 = 95 back a = a + 96 pure $ TypeID' (decodeUtf8 . BS.pack $ fmap back encodedPrefix) uuid @@ -761,7 +760,8 @@ decodeUUID :: ByteString -> Either TypeIDError UUID decodeUUID bs = do unless (BSL.length bs == 26) $ Left TypeIDErrorUUIDError unless (bs `BSL.index` 0 <= 55) $ Left TypeIDErrorUUIDError - when (any ((== 0xFF) . (base32Table !)) $ BSL.unpack bs) $ Left TypeIDErrorUUIDError + when (any ((== 0xFF) . (base32Table !)) $ BSL.unpack bs) do + Left TypeIDErrorUUIDError pure $ unsafeDecodeUUID bs {-# INLINE decodeUUID #-}