diff --git a/src/Data/Store/Internal.hs b/src/Data/Store/Internal.hs index 9ec80ac..9969c0b 100644 --- a/src/Data/Store/Internal.hs +++ b/src/Data/Store/Internal.hs @@ -443,6 +443,19 @@ instance Store LBS.ByteString where peek = fmap LBS.fromStrict peek instance Store T.Text where +#if MIN_VERSION_text(2,0,0) + size = VarSize $ \x -> + sizeOf (undefined :: Int) + + T.lengthWord8 x + poke x = do + let !(T.Text (TA.ByteArray array) w8Off w8Len) = x + poke w8Len + pokeFromByteArray array w8Off w8Len + peek = do + w8Len <- peek + ByteArray array <- peekToByteArray "Data.Text.Text" w8Len + return (T.Text (TA.ByteArray array) 0 w8Len) +#else size = VarSize $ \x -> sizeOf (undefined :: Int) + 2 * (T.lengthWord16 x) @@ -454,6 +467,7 @@ instance Store T.Text where w16Len <- peek ByteArray array <- peekToByteArray "Data.Text.Text" (2 * w16Len) return (T.Text (TA.Array array) 0 w16Len) +#endif ------------------------------------------------------------------------ -- Known size instances diff --git a/store-core/package.yaml b/store-core/package.yaml index 0854052..2fa7eea 100644 --- a/store-core/package.yaml +++ b/store-core/package.yaml @@ -31,7 +31,7 @@ dependencies: - bytestring >=0.10.4.0 && < 1.0 # soft - transformers >=0.3.0.0 && < 1.0 # soft - ghc-prim >=0.3.1.0 && < 1.0 # soft - - text >=1.2.0.4 && < 2.0 #soft + - text >=1.2.0.4 && < 1.3 || >= 2.0 && < 2.1 #soft library: source-dirs: src diff --git a/store-core/store-core.cabal b/store-core/store-core.cabal index 69d2b42..fb2a714 100644 --- a/store-core/store-core.cabal +++ b/store-core/store-core.cabal @@ -48,7 +48,7 @@ library , bytestring >=0.10.4.0 && <1.0 , ghc-prim >=0.3.1.0 && <1.0 , primitive >=0.6 && <1.0 - , text >=1.2.0.4 && <2.0 + , text >=1.2.0.4 && <1.3 || >=2.0 && <2.1 , transformers >=0.3.0.0 && <1.0 if flag(force-alignment) || arch(PPC) || arch(PPC64) || arch(Mips) || arch(Sparc) || arch(Arm) cpp-options: -DALIGNED_MEMORY