From e392dfa52d721c7ac23219582b57a25935373c9d Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Thu, 18 Jan 2018 23:41:29 +0100 Subject: [PATCH] Add support for new `compareByteArrays#` primop --- src-ghc804/PrimOps.hs | 6 ++++++ src/Data/Text/Short/Internal.hs | 2 +- text-short.cabal | 8 ++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 src-ghc804/PrimOps.hs diff --git a/src-ghc804/PrimOps.hs b/src-ghc804/PrimOps.hs new file mode 100644 index 0000000..b4faa72 --- /dev/null +++ b/src-ghc804/PrimOps.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE Unsafe #-} + +module PrimOps ( compareByteArrays# ) where + +import GHC.Exts (compareByteArrays#) diff --git a/src/Data/Text/Short/Internal.hs b/src/Data/Text/Short/Internal.hs index a4b66a5..0ad0563 100644 --- a/src/Data/Text/Short/Internal.hs +++ b/src/Data/Text/Short/Internal.hs @@ -92,7 +92,7 @@ import qualified PrimOps -- It can be shown that for realistic data . -- newtype ShortText = ShortText ShortByteString - deriving (Monoid,Semigroup,Hashable,NFData) + deriving (Monoid,Data.Semigroup.Semigroup,Hashable,NFData) instance Eq ShortText where {-# INLINE (==) #-} diff --git a/text-short.cabal b/text-short.cabal index 0ff5c71..317ecfc 100644 --- a/text-short.cabal +++ b/text-short.cabal @@ -37,8 +37,12 @@ library if !impl(ghc >= 8.0) build-depends: semigroups >= 0.18.2 && < 0.19 - c-sources: cbits/memcmp.c - hs-source-dirs: src-ghc708 + -- 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