packages feed

text-short 0.1.5 → 0.1.6

raw patch · 5 files changed

+97/−143 lines, 5 filesdep −semigroupsdep ~basedep ~binarydep ~bytestring

Dependencies removed: semigroups

Dependency ranges changed: base, binary, bytestring, deepseq, ghc-prim, hashable, tasty-quickcheck, template-haskell, text

Files

ChangeLog.md view
@@ -1,3 +1,8 @@+## 0.1.6++  * Drop support for GHC prior 8.6.5+  * Support GHC-9.10 (base-4.21)+ ## 0.1.5    * text-2.0 support
− cbits/memcmp.c
@@ -1,12 +0,0 @@-#include <string.h>--int-hs_text_short_memcmp(const void *s1, const size_t s1ofs, const void *s2, const size_t s2ofs, const size_t n)-{-  if (!n) return 0;--  const void *s1_ = s1+s1ofs;-  const void *s2_ = s2+s2ofs;--  return (s1_ == s2_) ? 0 : memcmp(s1_, s2_, n);-}
− src-ghc708/PrimOps.hs
@@ -1,23 +0,0 @@-{-# LANGUAGE MagicHash        #-}-{-# LANGUAGE UnliftedFFITypes #-}-{-# LANGUAGE Unsafe           #-}--module PrimOps ( compareByteArrays# ) where--import           Foreign.C.Types  (CInt (..), CSize (..))-import           GHC.Exts         (Int (I#))-import           GHC.Exts         (ByteArray#, Int#)-import           System.IO.Unsafe (unsafeDupablePerformIO)---- | Emulate GHC 8.4's 'GHC.Prim.compareByteArrays#'-compareByteArrays# :: ByteArray# -> Int# -> ByteArray# -> Int# -> Int# -> Int#-compareByteArrays# ba1# ofs1# ba2# ofs2# n#-    = unI (fromIntegral (unsafeDupablePerformIO (c_memcmp ba1# ofs1 ba2# ofs2 n)))-  where-    unI (I# i#) = i#-    ofs1 = fromIntegral (I# ofs1#)-    ofs2 = fromIntegral (I# ofs2#)-    n    = fromIntegral (I# n#)--foreign import ccall unsafe "hs_text_short_memcmp"-   c_memcmp :: ByteArray# -> CSize -> ByteArray# -> CSize -> CSize -> IO CInt
src/Data/Text/Short/Internal.hs view
@@ -4,18 +4,13 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MagicHash                  #-} {-# LANGUAGE RankNTypes                 #-}+{-# LANGUAGE TemplateHaskellQuotes      #-} {-# LANGUAGE TypeFamilies               #-} {-# LANGUAGE UnboxedTuples              #-} {-# LANGUAGE UnliftedFFITypes           #-} {-# LANGUAGE Unsafe                     #-} {-# LANGUAGE ViewPatterns               #-} -#if __GLASGOW_HASKELL__ >= 800-{-# LANGUAGE TemplateHaskellQuotes #-}-#else-{-# LANGUAGE TemplateHaskell #-}-#endif- -- | -- Module      : Data.Text.Short.Internal -- Copyright   : © Herbert Valerio Riedel 2017@@ -101,11 +96,18 @@     , BS.ByteString     , T.Text     , module Prelude+    , module Data.Monoid        -- ** Internals     , isValidUtf8     ) where +import           Prelude+  (Bool(..), Ordering(..), Int, Char, String, Maybe(..), IO, Eq, Ord, Num, Read,+   Show, ($), ($!), (.), (==), (/=), (+), (*), (-), (>>), (<=), (<), (>), (>=),+   compare, show, showsPrec, readsPrec, abs, return, fmap, error,+   undefined, otherwise, fromIntegral, max, min, not, fst, snd, map, seq, fail, maybe)+ import           Control.DeepSeq                (NFData) import           Control.Monad.ST               (stToIO) import           Data.Binary@@ -123,6 +125,7 @@ import           Data.Typeable                  (Typeable) import qualified Data.List                      as List import           Data.Maybe                     (fromMaybe, isNothing)+import           Data.Monoid                    (Monoid, mempty, mconcat) import           Data.Semigroup import qualified Data.String                    as S import qualified Data.Text                      as T@@ -136,12 +139,6 @@ import qualified GHC.Foreign                    as GHC import           GHC.IO.Encoding import           GHC.ST-import           Prelude                        hiding (all, any, break, concat,-                                                 drop, dropWhile, filter, foldl,-                                                 foldl1, foldr, foldr1, head,-                                                 init, last, length, null,-                                                 replicate, reverse, span,-                                                 splitAt, tail, take, takeWhile) import           System.IO.Unsafe import           Text.Printf                    (PrintfArg, formatArg,                                                  formatString)@@ -165,11 +162,12 @@ -- -- This type relates to 'T.Text' as 'ShortByteString' relates to 'BS.ByteString' by providing a more compact type. Please consult the documentation of "Data.ByteString.Short" for more information. ----- Currently, a boxed unshared 'T.Text' has a memory footprint of 6 words (i.e. 48 bytes on 64-bit systems) plus 2 or 4 bytes per code-point (due to the internal UTF-16 representation). Each 'T.Text' value which can share its payload with another 'T.Text' requires only 4 words additionally. Unlike 'BS.ByteString', 'T.Text' use unpinned memory.+-- Currently, a boxed unshared 'T.Text' has a memory footprint of 6 words (i.e. 48 bytes on 64-bit systems) plus 1, 2, 3 or 4 bytes per code-point for text-2 (due to the internal UTF-8 representation) or 2 or 4 bytes per  code-point for text-1 (due to the internal UTF-16 representation). Each 'T.Text' value which can share its payload with another 'T.Text' requires only 4 words additionally. Unlike 'BS.ByteString', 'T.Text' use unpinned memory. -- -- In comparison, the footprint of a boxed 'ShortText' is only 4 words (i.e. 32 bytes on 64-bit systems) plus 1, 2, 3, or 4 bytes per code-point (due to the internal UTF-8 representation).--- It can be shown that for realistic data <http://utf8everywhere.org/#asian UTF-16 has a space overhead of 50% over UTF-8>. --+-- It can be shown that for realistic data <http://utf8everywhere.org/#asian UTF-16, which is used by text-1, has a space overhead of 50% over UTF-8>.+-- -- __NOTE__: The `Typeable` instance isn't defined for GHC 7.8 (and older) prior to @text-short-0.1.3@ -- -- @since 0.1@@ -235,7 +233,6 @@   formatArg txt = formatString $ toString txt  -- | The 'Binary' encoding matches the one for 'T.Text'-#if MIN_VERSION_binary(0,8,1) instance Binary ShortText where     put = put . toShortByteString     get = do@@ -243,16 +240,6 @@         case fromShortByteString sbs of           Nothing -> fail "Binary.get(ShortText): Invalid UTF-8 stream"           Just st -> return st-#else--- fallback via 'ByteString' instance-instance Binary ShortText where-    put = put . toByteString-    get = do-        bs <- get-        case fromByteString bs of-          Nothing -> fail "Binary.get(ShortText): Invalid UTF-8 stream"-          Just st -> return st-#endif  -- | Since 0.1.3 instance TH.Lift ShortText where@@ -697,8 +684,8 @@  -- | \(\mathcal{O}(n)\) Construct 'ShortText' from 'T.Text' ----- This is currently not \(\mathcal{O}(1)\) because currently 'T.Text' uses UTF-16 as its internal representation.--- In the event that 'T.Text' will change its internal representation to UTF-8 this operation will become \(\mathcal{O}(1)\).+-- This is \(\mathcal{O}(1)\) with @text-2@ when the 'T.Text' is not sliced.+-- Previously it wasn't because 'T.Text' used UTF-16 as its internal representation. -- -- @since 0.1 fromText :: T.Text -> ShortText
text-short.cabal view
@@ -1,101 +1,98 @@-cabal-version:       1.18-name:                text-short-version:             0.1.5-synopsis:            Memory-efficient representation of Unicode text strings-license:             BSD3-license-file:        LICENSE-author:              Herbert Valerio Riedel-maintainer:          hvr@gnu.org-bug-reports:         https://github.com/hvr/text-short/issues-category:            Data-build-type:          Simple-description:         This package provides the 'ShortText' type which is suitable for keeping many short strings in memory. This is similiar to how 'ShortByteString' relates to 'ByteString'.-                     .-                     The main difference between 'Text' and 'ShortText' is that 'ShortText' uses UTF-8 instead of UTF-16 internally and also doesn't support zero-copy slicing (thereby saving 2 words). Consequently, the memory footprint of a (boxed) 'ShortText' value is 4 words (2 words when unboxed) plus the length of the UTF-8 encoded payload.+cabal-version:      1.18+name:               text-short+version:            0.1.6+synopsis:           Memory-efficient representation of Unicode text strings+license:            BSD3+license-file:       LICENSE+author:             Herbert Valerio Riedel+maintainer:         hvr@gnu.org+bug-reports:        https://github.com/hvr/text-short/issues+category:           Data+build-type:         Simple+description:+  This package provides the 'ShortText' type which is suitable for keeping many short strings in memory. This is similiar to how 'ShortByteString' relates to 'ByteString'.+  .+  The main difference between 'Text' and 'ShortText' is that 'ShortText' doesn't support zero-copy slicing (thereby saving 2 words), and, compared to text-1.*, that it uses UTF-8 instead of UTF-16 internally. Consequently, the memory footprint of a (boxed) 'ShortText' value is 4 words (2 words when unboxed) plus the length of the UTF-8 encoded payload. -tested-with:         GHC==9.0.1, GHC==8.10.4, GHC==8.8.3, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==9.2.1-extra-source-files:  ChangeLog.md+tested-with:+  GHC ==8.6.5+   || ==8.8.3+   || ==8.10.7+   || ==9.0.2+   || ==9.2.8+   || ==9.4.8+   || ==9.6.5+   || ==9.8.2 -Source-Repository head-    Type:              git-    Location:          https://github.com/hvr/text-short.git+extra-source-files: ChangeLog.md +source-repository head+  type:     git+  location: https://github.com/hvr/text-short.git+ flag asserts   description: Enable runtime-checks via @assert@-  default: False-  manual: True+  default:     False+  manual:      True  library-  exposed-modules:     Data.Text.Short-                       Data.Text.Short.Partial-                       Data.Text.Short.Unsafe--  other-modules:       Data.Text.Short.Internal--  build-depends:       base        >= 4.7    && < 4.17-                     , bytestring  >= 0.10.4 && < 0.12-                     , hashable    >= 1.2.6  && < 1.5-                     , deepseq     >= 1.3    && < 1.5-                     , text        >= 1.0    && < 1.3 || >=2.0 && <2.1-                     , binary      >= 0.7.1  && < 0.9-                     , ghc-prim    >= 0.3.1  && < 0.9-                     , template-haskell >= 2.9.0.0 && <2.19--  if impl(ghc >=8.0)-    build-depends: bytestring >= 0.10.8.0--  if !impl(ghc >= 8.0)-     build-depends: semigroups >= 0.18.2 && < 0.21--  -- GHC version specific PrimOps-  if impl(ghc >= 8.4)-     hs-source-dirs:   src-ghc804-  else-     c-sources:        cbits/memcmp.c-     hs-source-dirs:   src-ghc708-  other-modules:       PrimOps--  hs-source-dirs:      src+  exposed-modules:+    Data.Text.Short+    Data.Text.Short.Partial+    Data.Text.Short.Unsafe -  default-language:    Haskell2010-  other-extensions:    CPP-                     , GeneralizedNewtypeDeriving-                     , MagicHash-                     , UnliftedFFITypes-                     , Trustworthy-                     , Unsafe+  other-modules:    Data.Text.Short.Internal+  build-depends:+      base              >=4.12     && <4.20+    , binary            >=0.8.6.0  && <0.9+    , bytestring        >=0.10.8.2 && <0.13+    , deepseq           >=1.4.4.0  && <1.6+    , ghc-prim          >=0.5.3    && <0.12+    , hashable          >=1.4.4.0  && <1.5+    , template-haskell  >=2.14.0.0 && <2.22+    , text              >=1.2.3.1  && <1.3  || >=2.0 && <2.2 -  if impl(ghc >= 8)-    other-extensions: TemplateHaskellQuotes-  else-    other-extensions: TemplateHaskell+  other-modules:    PrimOps+  hs-source-dirs:   src src-ghc804+  default-language: Haskell2010+  other-extensions:+    CPP+    GeneralizedNewtypeDeriving+    MagicHash+    TemplateHaskellQuotes+    Trustworthy+    UnliftedFFITypes+    Unsafe -  c-sources: cbits/cbits.c+  c-sources:        cbits/cbits.c    if flag(asserts)-     ghc-options: -fno-ignore-asserts+    ghc-options: -fno-ignore-asserts+   else-     cc-options: -DNDEBUG=1+    cc-options: -DNDEBUG=1 -  ghc-options: -Wall-  cc-options: -Wall+  ghc-options:      -Wall+  cc-options:       -Wall -test-suite tests-  type:                exitcode-stdio-1.0-  hs-source-dirs:      src-test-  main-is:             Tests.hs+test-suite text-short-tests+  type:             exitcode-stdio-1.0+  hs-source-dirs:   src-test+  main-is:          Tests.hs    -- bytestring dependency for cabal_macros.h-  build-depends: base-               , bytestring-               , binary-               , text-               , text-short-               , template-haskell+  build-depends:+      base+    , binary+    , bytestring+    , template-haskell+    , text+    , text-short    -- deps which don't inherit constraints from library stanza:-  build-depends: tasty                >= 1.4    && < 1.5-               , tasty-quickcheck     >= 0.10   && < 0.11-               , tasty-hunit          >= 0.10.0 && < 0.11+  build-depends:+      tasty             >=1.4    && <1.6+    , tasty-hunit       >=0.10.0 && <0.11+    , tasty-quickcheck  >=0.10   && <0.11 -  default-language:    Haskell2010+  default-language: Haskell2010