Commits

lpsmith  committed 80d0be6

Better support for GHC < 7.8

  • Participants
  • Parent commits c1fab56

Comments (0)

Files changed (3)

File Data/Text/Encoding.hs

     , encodeUtf32LE
     , encodeUtf32BE
 
-#if MIN_VERSION_bytestring(0,10,4)
     -- * Encoding Text using ByteString Builders
-    -- | /Note/ that these functions are only available if built against
-    -- @bytestring >= 0.10.4.0@.
     , encodeUtf8Builder
     , encodeUtf8BuilderEscaped
-#endif
     ) where
 
 #if __GLASGOW_HASKELL__ >= 702
 import Control.Monad.ST (unsafeIOToST, unsafeSTToIO)
 #endif
 
-#if MIN_VERSION_bytestring(0,10,4)
 import Data.Bits ((.&.))
 import Data.Text.Internal.Unsafe.Char (ord)
 import qualified Data.ByteString.Builder as B
 import qualified Data.ByteString.Builder.Prim as BP
 import qualified Data.ByteString.Builder.Prim.Internal as BP
 import qualified Data.Text.Internal.Encoding.Utf16 as U16
-#endif
 
 import Control.Exception (evaluate, try)
 import Control.Monad.ST (runST)
 decodeUtf8' = unsafeDupablePerformIO . try . evaluate . decodeUtf8With strictDecode
 {-# INLINE decodeUtf8' #-}
 
-#if MIN_VERSION_bytestring(0,10,4)
-
 -- | Encode text to a ByteString 'B.Builder' using UTF-8 encoding.
 encodeUtf8Builder :: Text -> B.Builder
 encodeUtf8Builder = encodeUtf8BuilderEscaped (BP.liftFixedToBounded BP.word8)
                       outerLoop i (B.BufferRange op ope)
                   where
                     poke8 j v = poke (op `plusPtr` j) (fromIntegral v :: Word8)
-#endif
 
 -- | Encode text using UTF-8 encoding.
 encodeUtf8 :: Text -> ByteString

File Data/Text/Lazy/Encoding.hs

     , encodeUtf32LE
     , encodeUtf32BE
 
-#if MIN_VERSION_bytestring(0,10,4)
     -- * Encoding Text using ByteString Builders
     , encodeUtf8Builder
     , encodeUtf8BuilderEscaped
-#endif
     ) where
 
 import Control.Exception (evaluate, try)
 import qualified Data.ByteString.Lazy as B
 import qualified Data.ByteString.Lazy.Internal as B
 import qualified Data.ByteString.Unsafe as B
-#if MIN_VERSION_bytestring(0,10,4)
+
 import Data.Word (Word8)
 import Data.Monoid (mempty, (<>))
 import qualified Data.ByteString.Builder as B
 import qualified Data.ByteString.Builder.Extra as B (safeStrategy, toLazyByteStringWith)
 import qualified Data.ByteString.Builder.Prim as BP
 import qualified Data.Text as T
-#endif
+
 import qualified Data.Text.Encoding as TE
 import qualified Data.Text.Lazy as L
 import qualified Data.Text.Internal.Lazy.Encoding.Fusion as E
 {-# INLINE decodeUtf8' #-}
 
 encodeUtf8 :: Text -> B.ByteString
-#if MIN_VERSION_bytestring(0,10,4)
 encodeUtf8    Empty       = B.empty
 encodeUtf8 lt@(Chunk t _) =
     B.toLazyByteStringWith strategy B.empty $ encodeUtf8Builder lt
 encodeUtf8BuilderEscaped prim =
     foldrChunks (\c b -> TE.encodeUtf8BuilderEscaped prim c <> b) mempty
 
-#else
-encodeUtf8 (Chunk c cs) = B.Chunk (TE.encodeUtf8 c) (encodeUtf8 cs)
-encodeUtf8 Empty        = B.Empty
-#endif
-
 -- | Decode text from little endian UTF-16 encoding.
 decodeUtf16LEWith :: OnDecodeError -> B.ByteString -> Text
 decodeUtf16LEWith onErr bs = F.unstream (E.streamUtf16LE onErr bs)
 name:           text
-version:        1.1.0.0
+version:        1.1.1.0
 homepage:       https://github.com/bos/text
 bug-reports:    https://github.com/bos/text/issues
 synopsis:       An efficient packed Unicode text type.
   build-depends:
     array      >= 0.3,
     base       >= 4.2 && < 5,
+    bytestring >= 0.9,
     deepseq    >= 1.1.0.0,
     ghc-prim   >= 0.2
 
-  if impl(ghc >= 7.7)
-    build-depends: bytestring >= 0.10.4.0
-  else
-    build-depends: bytestring >= 0.9
+  if impl(ghc < 7.8)
+    build-depends: bytestring-builder
 
   cpp-options: -DHAVE_DEEPSEQ
   ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2
     test-framework-hunit >= 0.2,
     test-framework-quickcheck2 >= 0.2
 
+  if impl(ghc < 7.8)
+    build-depends: bytestring-builder
+
   if flag(integer-simple)
     cpp-options: -DINTEGER_SIMPLE
     build-depends: integer-simple >= 0.1 && < 0.5