Skip to content
Browse files

Depend on Text only when compiling using GHC.

  • Loading branch information...
1 parent 61b4c6f commit febf9b0f64efa0834f862e34cce8dd0600de5c68 @foxik foxik committed
Showing with 7 additions and 3 deletions.
  1. +4 −1 Data/Hashable.hs
  2. +3 −2 hashable.cabal
View
5 Data/Hashable.hs
@@ -48,10 +48,12 @@ import qualified Data.ByteString.Internal as B
import qualified Data.ByteString.Unsafe as B
import qualified Data.ByteString.Lazy as BL
import qualified Data.ByteString.Lazy.Internal as BL
+#if defined(__GLASGOW_HASKELL__)
import qualified Data.Text as T
import qualified Data.Text.Array as TA
import qualified Data.Text.Internal as T
import qualified Data.Text.Lazy as LT
+#endif
import Foreign.C (CString)
#if __GLASGOW_HASKELL__ >= 703
import Foreign.C (CLong(..))
@@ -299,6 +301,7 @@ instance Hashable BL.ByteString where
hash = hashWithSalt stringSalt
hashWithSalt = BL.foldlChunks hashWithSalt
+#if defined(__GLASGOW_HASKELL__)
instance Hashable T.Text where
hash = hashWithSalt stringSalt
hashWithSalt salt (T.Text arr off len) =
@@ -308,7 +311,7 @@ instance Hashable T.Text where
instance Hashable LT.Text where
hash = hashWithSalt stringSalt
hashWithSalt = LT.foldlChunks hashWithSalt
-
+#endif
-- | Compute the hash of a TypeRep, in various GHC versions we can do this quickly.
hashTypeRep :: TypeRep -> Int
View
5 hashable.cabal
@@ -30,8 +30,9 @@ Flag integer-gmp
Library
Exposed-modules: Data.Hashable
Build-depends: base >= 4.0 && < 5,
- bytestring >= 0.9 && < 1.0,
- ghc-prim < 0.3,
+ bytestring >= 0.9 && < 1.0
+ if impl(ghc)
+ Build-depends: ghc-prim < 0.3,
text >= 0.11.0.5 && < 0.12
if impl(ghc) && flag(integer-gmp)
Build-depends: integer-gmp >= 0.2

0 comments on commit febf9b0

Please sign in to comment.
Something went wrong with that request. Please try again.