streaming-commons 0.2.2.2 → 0.2.2.3
raw patch · 8 files changed
+71/−513 lines, 8 filesdep ~text
Dependency ranges changed: text
Files
- ChangeLog.md +4/−0
- Data/Streaming/Text.hs +65/−12
- Data/Text/Internal/Encoding/Utf16.hs +0/−54
- Data/Text/Internal/Encoding/Utf32.hs +0/−26
- Data/Text/Internal/Encoding/Utf8.hs +0/−176
- Data/Text/Internal/Unsafe/Char.hs +0/−119
- Data/Text/Internal/Unsafe/Shift.hs +0/−116
- streaming-commons.cabal +2/−10
ChangeLog.md view
@@ -1,5 +1,9 @@ # ChangeLog for streaming-commons +## 0.2.2.3++* Support text 2.0 [#65](https://github.com/fpco/streaming-commons/pull/65)+ ## 0.2.2.2 * Support GHC 9.2 [#62](https://github.com/fpco/streaming-commons/pull/62)
Data/Streaming/Text.hs view
@@ -4,6 +4,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE Rank2Types #-}+{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UnliftedFFITypes #-} --@@ -48,7 +49,7 @@ import Control.Monad.ST (ST, runST) import Control.Monad.ST.Unsafe (unsafeIOToST, unsafeSTToIO)-import Data.Bits ((.|.))+import Data.Bits ((.|.), shiftL) import qualified Data.ByteString as B import Data.ByteString.Internal (ByteString (PS)) import qualified Data.ByteString.Unsafe as B@@ -59,10 +60,8 @@ import qualified Data.Text.Internal.Encoding.Utf16 as U16 import qualified Data.Text.Internal.Encoding.Utf32 as U32 import qualified Data.Text.Internal.Encoding.Utf8 as U8-import Data.Text.Internal.Unsafe.Char (unsafeChr, unsafeChr32,+import Data.Text.Internal.Unsafe.Char (unsafeWrite, unsafeChr32, unsafeChr8)-import Data.Text.Internal.Unsafe.Char (unsafeWrite)-import Data.Text.Internal.Unsafe.Shift (shiftL) import Data.Word (Word32, Word8) import Foreign.C.Types (CSize (..)) import Foreign.ForeignPtr (withForeignPtr)@@ -72,6 +71,17 @@ import Foreign.Storable (Storable, peek, poke) import GHC.Base (MutableByteArray#) +#if MIN_VERSION_text(2,0,0)+import Control.Exception (try, evaluate)+import qualified Data.Text.Encoding as TE+import qualified Data.Text.Encoding.Error as TE+import Data.Text.Internal.Unsafe.Char (unsafeChr16)+import System.IO.Unsafe (unsafePerformIO)+#else+import Data.Text.Internal.Unsafe.Char (unsafeChr)+unsafeChr16 = unsafeChr+#endif+ data S = S0 | S1 {-# UNPACK #-} !Word8 | S2 {-# UNPACK #-} !Word8 {-# UNPACK #-} !Word8@@ -108,6 +118,16 @@ -- | /O(n)/ Convert a 'ByteString' into a 'Stream Char', using -- UTF-8 encoding. decodeUtf8 :: B.ByteString -> DecodeResult+#if MIN_VERSION_text(2,0,0)+decodeUtf8 = go mempty TE.streamDecodeUtf8+ where+ go :: B.ByteString -> (B.ByteString -> TE.Decoding) -> B.ByteString -> DecodeResult+ go prev decoder curr = case unsafePerformIO (try (evaluate (decoder curr))) of+ -- Caught exception does not allow to reconstruct 'DecodeResultFailure',+ -- so delegating this to 'decodeUtf8Pure'+ Left (_ :: TE.UnicodeException) -> decodeUtf8Pure (prev <> curr)+ Right (TE.Some decoded undecoded cont) -> DecodeResultSuccess decoded (go undecoded cont)+#else decodeUtf8 = decodeChunk B.empty 0 0 where decodeChunkCheck :: B.ByteString -> CodePoint -> DecoderState -> B.ByteString -> DecodeResult@@ -158,6 +178,7 @@ return $! DecodeResultSuccess chunkText $! decodeChunkCheck unused codepoint state in loop (ptr `plusPtr` off)+#endif -- | /O(n)/ Convert a 'ByteString' into a 'Stream Char', using -- UTF-8 encoding.@@ -172,7 +193,13 @@ _ -> DecodeResultFailure T.empty $ toBS s beginChunk s0 ps = runST $ do let initLen = B.length ps+#if MIN_VERSION_text(2,0,0)+ -- Worst-case scenario: the very first byte finishes a 4-byte sequence,+ -- so decoding results in 4 + (initLen - 1) bytes.+ marr <- A.new (initLen + 3)+#else marr <- A.new (initLen + 1)+#endif let start !i !j | i >= len = do t <- getText j marr@@ -237,12 +264,18 @@ _ -> DecodeResultFailure T.empty $ toBS s beginChunk s0 ps = runST $ do let initLen = B.length ps- marr <- A.new (initLen + 1)+#if MIN_VERSION_text(2,0,0)+ -- Worst-case scenario: each Word16 in UTF16 gives three Word8 in UTF8+ -- and left-over from a previous chunk gives four Word8 in UTF8+ marr <- A.new ((initLen `div` 2) * 3 + 4) -- of Word8+#else+ marr <- A.new (initLen + 1) -- of Word16+#endif let start !i !j | i >= len = do t <- getText j marr return $! DecodeResultSuccess t (beginChunk S0)- | i + 1 < len && U16.validate1 x1 = addChar' 2 (unsafeChr x1)+ | i + 1 < len && U16.validate1 x1 = addChar' 2 (unsafeChr16 x1) | i + 3 < len && U16.validate2 x1 x2 = addChar' 4 (U16.chr2 x1 x2) | i + 3 < len = do t <- getText j marr@@ -271,7 +304,7 @@ S1 a -> let x1 = combine a x in if U16.validate1 x1- then addChar' (unsafeChr x1)+ then addChar' (unsafeChr16 x1) else checkCont (S2 a x) (i + 1) S2 a b -> checkCont (S3 a b x) (i + 1) S3 a b c ->@@ -306,12 +339,18 @@ _ -> DecodeResultFailure T.empty $ toBS s beginChunk s0 ps = runST $ do let initLen = B.length ps- marr <- A.new (initLen + 1)+#if MIN_VERSION_text(2,0,0)+ -- Worst-case scenario: each Word16 in UTF16 gives three Word8 in UTF8+ -- and left-over from a previous chunk gives four Word8 in UTF8+ marr <- A.new ((initLen `div` 2) * 3 + 4) -- of Word8+#else+ marr <- A.new (initLen + 1) -- of Word16+#endif let start !i !j | i >= len = do t <- getText j marr return $! DecodeResultSuccess t (beginChunk S0)- | i + 1 < len && U16.validate1 x1 = addChar' 2 (unsafeChr x1)+ | i + 1 < len && U16.validate1 x1 = addChar' 2 (unsafeChr16 x1) | i + 3 < len && U16.validate2 x1 x2 = addChar' 4 (U16.chr2 x1 x2) | i + 3 < len = do t <- getText j marr@@ -340,7 +379,7 @@ S1 a -> let x1 = combine a x in if U16.validate1 x1- then addChar' (unsafeChr x1)+ then addChar' (unsafeChr16 x1) else checkCont (S2 a x) (i + 1) S2 a b -> checkCont (S3 a b x) (i + 1) S3 a b c ->@@ -375,7 +414,14 @@ _ -> DecodeResultFailure T.empty $ toBS s beginChunk s0 ps = runST $ do let initLen = B.length ps `div` 2- marr <- A.new (initLen + 1)+#if MIN_VERSION_text(2,0,0)+ -- | Worst-case scenario: the very first byte finishes a 4-byte UTF8 sequence,+ -- and other codepoints have 4-byte UTF8 representation as well.+ -- This gives 4 + (B.length ps - 1), or (for odd B.length) initLen * 2 + 4.+ marr <- A.new (initLen * 2 + 4) -- of Word8+#else+ marr <- A.new (initLen + 1) -- of Word16+#endif let start !i !j | i >= len = do t <- getText j marr@@ -441,7 +487,14 @@ _ -> DecodeResultFailure T.empty $ toBS s beginChunk s0 ps = runST $ do let initLen = B.length ps `div` 2- marr <- A.new (initLen + 1)+#if MIN_VERSION_text(2,0,0)+ -- | Worst-case scenario: the very first byte finishes a 4-byte UTF8 sequence,+ -- and other codepoints have 4-byte UTF8 representation as well.+ -- This gives 4 + (B.length ps - 1), or (for odd B.length) initLen * 2 + 4.+ marr <- A.new (initLen * 2 + 4) -- of Word8+#else+ marr <- A.new (initLen + 1) -- of Word16+#endif let start !i !j | i >= len = do t <- getText j marr
− Data/Text/Internal/Encoding/Utf16.hs
@@ -1,54 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE MagicHash, BangPatterns #-}---- |--- Module : Data.Text.Internal.Encoding.Utf16--- Copyright : (c) 2008, 2009 Tom Harper,--- (c) 2009 Bryan O'Sullivan,--- (c) 2009 Duncan Coutts------ License : BSD-style--- Maintainer : bos@serpentine.com--- Stability : experimental--- Portability : GHC------ /Warning/: this is an internal module, and does not have a stable--- API or name. Functions in this module may not check or enforce--- preconditions expected by public modules. Use at your own risk!------ Basic UTF-16 validation and character manipulation.-module Data.Text.Internal.Encoding.Utf16- (- chr2- , validate1- , validate2- ) where--import GHC.Exts-import GHC.Word (Word16(..))--chr2 :: Word16 -> Word16 -> Char-chr2 (W16# a#) (W16# b#) = C# (chr# (upper# +# lower# +# 0x10000#))- where- !x# = word2Int# (word16ToWordCompat# a#)- !y# = word2Int# (word16ToWordCompat# b#)- !upper# = uncheckedIShiftL# (x# -# 0xD800#) 10#- !lower# = y# -# 0xDC00#-{-# INLINE chr2 #-}--validate1 :: Word16 -> Bool-validate1 x1 = x1 < 0xD800 || x1 > 0xDFFF-{-# INLINE validate1 #-}--validate2 :: Word16 -> Word16 -> Bool-validate2 x1 x2 = x1 >= 0xD800 && x1 <= 0xDBFF &&- x2 >= 0xDC00 && x2 <= 0xDFFF-{-# INLINE validate2 #-}--#if MIN_VERSION_base(4,16,0)-word16ToWordCompat# :: Word16# -> Word#-word16ToWordCompat# = word16ToWord#-#else-word16ToWordCompat# :: Word# -> Word#-word16ToWordCompat# x = x-#endif
− Data/Text/Internal/Encoding/Utf32.hs
@@ -1,26 +0,0 @@--- |--- Module : Data.Text.Internal.Encoding.Utf32--- Copyright : (c) 2008, 2009 Tom Harper,--- (c) 2009, 2010 Bryan O'Sullivan,--- (c) 2009 Duncan Coutts------ License : BSD-style--- Maintainer : bos@serpentine.com--- Stability : experimental--- Portability : portable------ /Warning/: this is an internal module, and does not have a stable--- API or name. Functions in this module may not check or enforce--- preconditions expected by public modules. Use at your own risk!------ Basic UTF-32 validation.-module Data.Text.Internal.Encoding.Utf32- (- validate- ) where--import Data.Word (Word32)--validate :: Word32 -> Bool-validate x1 = x1 < 0xD800 || (x1 > 0xDFFF && x1 <= 0x10FFFF)-{-# INLINE validate #-}
− Data/Text/Internal/Encoding/Utf8.hs
@@ -1,176 +0,0 @@-{-# LANGUAGE CPP, MagicHash, BangPatterns #-}---- |--- Module : Data.Text.Internal.Encoding.Utf8--- Copyright : (c) 2008, 2009 Tom Harper,--- (c) 2009, 2010 Bryan O'Sullivan,--- (c) 2009 Duncan Coutts------ License : BSD-style--- Maintainer : bos@serpentine.com--- Stability : experimental--- Portability : GHC------ /Warning/: this is an internal module, and does not have a stable--- API or name. Functions in this module may not check or enforce--- preconditions expected by public modules. Use at your own risk!------ Basic UTF-8 validation and character manipulation.-module Data.Text.Internal.Encoding.Utf8- (- -- Decomposition- ord2- , ord3- , ord4- -- Construction- , chr2- , chr3- , chr4- -- * Validation- , validate1- , validate2- , validate3- , validate4- ) where--#if defined(TEST_SUITE)-# undef ASSERTS-#endif--#if defined(ASSERTS)-import Control.Exception (assert)-#endif-import Data.Bits ((.&.))-import Data.Text.Internal.Unsafe.Char (ord)-import Data.Text.Internal.Unsafe.Shift (shiftR)-import GHC.Exts-import GHC.Word (Word8(..))--default(Int)--between :: Word8 -- ^ byte to check- -> Word8 -- ^ lower bound- -> Word8 -- ^ upper bound- -> Bool-between x y z = x >= y && x <= z-{-# INLINE between #-}--ord2 :: Char -> (Word8,Word8)-ord2 c =-#if defined(ASSERTS)- assert (n >= 0x80 && n <= 0x07ff)-#endif- (x1,x2)- where- n = ord c- x1 = fromIntegral $ (n `shiftR` 6) + 0xC0- x2 = fromIntegral $ (n .&. 0x3F) + 0x80--ord3 :: Char -> (Word8,Word8,Word8)-ord3 c =-#if defined(ASSERTS)- assert (n >= 0x0800 && n <= 0xffff)-#endif- (x1,x2,x3)- where- n = ord c- x1 = fromIntegral $ (n `shiftR` 12) + 0xE0- x2 = fromIntegral $ ((n `shiftR` 6) .&. 0x3F) + 0x80- x3 = fromIntegral $ (n .&. 0x3F) + 0x80--ord4 :: Char -> (Word8,Word8,Word8,Word8)-ord4 c =-#if defined(ASSERTS)- assert (n >= 0x10000)-#endif- (x1,x2,x3,x4)- where- n = ord c- x1 = fromIntegral $ (n `shiftR` 18) + 0xF0- x2 = fromIntegral $ ((n `shiftR` 12) .&. 0x3F) + 0x80- x3 = fromIntegral $ ((n `shiftR` 6) .&. 0x3F) + 0x80- x4 = fromIntegral $ (n .&. 0x3F) + 0x80--chr2 :: Word8 -> Word8 -> Char-chr2 (W8# x1#) (W8# x2#) = C# (chr# (z1# +# z2#))- where- !y1# = word2Int# (word8ToWordCompat# x1#)- !y2# = word2Int# (word8ToWordCompat# x2#)- !z1# = uncheckedIShiftL# (y1# -# 0xC0#) 6#- !z2# = y2# -# 0x80#-{-# INLINE chr2 #-}--chr3 :: Word8 -> Word8 -> Word8 -> Char-chr3 (W8# x1#) (W8# x2#) (W8# x3#) = C# (chr# (z1# +# z2# +# z3#))- where- !y1# = word2Int# (word8ToWordCompat# x1#)- !y2# = word2Int# (word8ToWordCompat# x2#)- !y3# = word2Int# (word8ToWordCompat# x3#)- !z1# = uncheckedIShiftL# (y1# -# 0xE0#) 12#- !z2# = uncheckedIShiftL# (y2# -# 0x80#) 6#- !z3# = y3# -# 0x80#-{-# INLINE chr3 #-}--chr4 :: Word8 -> Word8 -> Word8 -> Word8 -> Char-chr4 (W8# x1#) (W8# x2#) (W8# x3#) (W8# x4#) =- C# (chr# (z1# +# z2# +# z3# +# z4#))- where- !y1# = word2Int# (word8ToWordCompat# x1#)- !y2# = word2Int# (word8ToWordCompat# x2#)- !y3# = word2Int# (word8ToWordCompat# x3#)- !y4# = word2Int# (word8ToWordCompat# x4#)- !z1# = uncheckedIShiftL# (y1# -# 0xF0#) 18#- !z2# = uncheckedIShiftL# (y2# -# 0x80#) 12#- !z3# = uncheckedIShiftL# (y3# -# 0x80#) 6#- !z4# = y4# -# 0x80#-{-# INLINE chr4 #-}--validate1 :: Word8 -> Bool-validate1 x1 = x1 <= 0x7F-{-# INLINE validate1 #-}--validate2 :: Word8 -> Word8 -> Bool-validate2 x1 x2 = between x1 0xC2 0xDF && between x2 0x80 0xBF-{-# INLINE validate2 #-}--validate3 :: Word8 -> Word8 -> Word8 -> Bool-{-# INLINE validate3 #-}-validate3 x1 x2 x3 = validate3_1 || validate3_2 || validate3_3 || validate3_4- where- validate3_1 = (x1 == 0xE0) &&- between x2 0xA0 0xBF &&- between x3 0x80 0xBF- validate3_2 = between x1 0xE1 0xEC &&- between x2 0x80 0xBF &&- between x3 0x80 0xBF- validate3_3 = x1 == 0xED &&- between x2 0x80 0x9F &&- between x3 0x80 0xBF- validate3_4 = between x1 0xEE 0xEF &&- between x2 0x80 0xBF &&- between x3 0x80 0xBF--validate4 :: Word8 -> Word8 -> Word8 -> Word8 -> Bool-{-# INLINE validate4 #-}-validate4 x1 x2 x3 x4 = validate4_1 || validate4_2 || validate4_3- where- validate4_1 = x1 == 0xF0 &&- between x2 0x90 0xBF &&- between x3 0x80 0xBF &&- between x4 0x80 0xBF- validate4_2 = between x1 0xF1 0xF3 &&- between x2 0x80 0xBF &&- between x3 0x80 0xBF &&- between x4 0x80 0xBF- validate4_3 = x1 == 0xF4 &&- between x2 0x80 0x8F &&- between x3 0x80 0xBF &&- between x4 0x80 0xBF--#if MIN_VERSION_base(4,16,0)-word8ToWordCompat# :: Word8# -> Word#-word8ToWordCompat# = word8ToWord#-#else-word8ToWordCompat# :: Word# -> Word#-word8ToWordCompat# x = x-#endif
− Data/Text/Internal/Unsafe/Char.hs
@@ -1,119 +0,0 @@-{-# LANGUAGE CPP, MagicHash #-}---- |--- Module : Data.Text.Internal.Unsafe.Char--- Copyright : (c) 2008, 2009 Tom Harper,--- (c) 2009, 2010 Bryan O'Sullivan,--- (c) 2009 Duncan Coutts------ License : BSD-style--- Maintainer : bos@serpentine.com--- Stability : experimental--- Portability : GHC------ /Warning/: this is an internal module, and does not have a stable--- API or name. Functions in this module may not check or enforce--- preconditions expected by public modules. Use at your own risk!------ Fast character manipulation functions.-module Data.Text.Internal.Unsafe.Char- (- ord- , unsafeChr- , unsafeChr8- , unsafeChr32- , unsafeWrite- -- , unsafeWriteRev- ) where--#ifdef ASSERTS-import Control.Exception (assert)-#endif-import Control.Monad.ST (ST)-import Data.Bits ((.&.))-import Data.Text.Internal.Unsafe.Shift (shiftR)-import GHC.Exts (Char(..), Int(..), Word#, chr#, ord#, word2Int#)-import GHC.Word (Word8(..), Word16(..), Word32(..))-import qualified Data.Text.Array as A--#if MIN_VERSION_base(4,16,0)-import GHC.Exts (Word8#, Word16#, Word32#, word8ToWord#, word16ToWord#, word32ToWord#)-#endif--ord :: Char -> Int-ord (C# c#) = I# (ord# c#)-{-# INLINE ord #-}--unsafeChr :: Word16 -> Char-unsafeChr (W16# w#) = C# (chr# (word2Int# (word16ToWordCompat# w#)))-{-# INLINE unsafeChr #-}--unsafeChr8 :: Word8 -> Char-unsafeChr8 (W8# w#) = C# (chr# (word2Int# (word8ToWordCompat# w#)))-{-# INLINE unsafeChr8 #-}--unsafeChr32 :: Word32 -> Char-unsafeChr32 (W32# w#) = C# (chr# (word2Int# (word32ToWordCompat# w#)))-{-# INLINE unsafeChr32 #-}---- | Write a character into the array at the given offset. Returns--- the number of 'Word16's written.-unsafeWrite :: A.MArray s -> Int -> Char -> ST s Int-unsafeWrite marr i c- | n < 0x10000 = do-#if defined(ASSERTS)- assert (i >= 0) . assert (i < A.length marr) $ return ()-#endif- A.unsafeWrite marr i (fromIntegral n)- return 1- | otherwise = do-#if defined(ASSERTS)- assert (i >= 0) . assert (i < A.length marr - 1) $ return ()-#endif- A.unsafeWrite marr i lo- A.unsafeWrite marr (i+1) hi- return 2- where n = ord c- m = n - 0x10000- lo = fromIntegral $ (m `shiftR` 10) + 0xD800- hi = fromIntegral $ (m .&. 0x3FF) + 0xDC00-{-# INLINE unsafeWrite #-}--{--unsafeWriteRev :: A.MArray s Word16 -> Int -> Char -> ST s Int-unsafeWriteRev marr i c- | n < 0x10000 = do- assert (i >= 0) . assert (i < A.length marr) $- A.unsafeWrite marr i (fromIntegral n)- return (i-1)- | otherwise = do- assert (i >= 1) . assert (i < A.length marr) $- A.unsafeWrite marr (i-1) lo- A.unsafeWrite marr i hi- return (i-2)- where n = ord c- m = n - 0x10000- lo = fromIntegral $ (m `shiftR` 10) + 0xD800- hi = fromIntegral $ (m .&. 0x3FF) + 0xDC00-{-# INLINE unsafeWriteRev #-}--}--#if MIN_VERSION_base(4,16,0)-word8ToWordCompat# :: Word8# -> Word#-word8ToWordCompat# = word8ToWord#--word16ToWordCompat# :: Word16# -> Word#-word16ToWordCompat# = word16ToWord#--word32ToWordCompat# :: Word32# -> Word#-word32ToWordCompat# = word32ToWord#-#else-word8ToWordCompat# :: Word# -> Word#-word8ToWordCompat# x = x--word16ToWordCompat# :: Word# -> Word#-word16ToWordCompat# x = x--word32ToWordCompat# :: Word# -> Word#-word32ToWordCompat# x = x-#endif
− Data/Text/Internal/Unsafe/Shift.hs
@@ -1,116 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE MagicHash #-}---- |--- Module : Data.Text.Internal.Unsafe.Shift--- Copyright : (c) Bryan O'Sullivan 2009------ License : BSD-style--- Maintainer : bos@serpentine.com--- Stability : experimental--- Portability : GHC------ /Warning/: this is an internal module, and does not have a stable--- API or name. Functions in this module may not check or enforce--- preconditions expected by public modules. Use at your own risk!------ Fast, unchecked bit shifting functions.--module Data.Text.Internal.Unsafe.Shift- (- UnsafeShift(..)- ) where---- import qualified Data.Bits as Bits-import GHC.Base-#if __GLASGOW_HASKELL__ >= 903- hiding (uncheckedShiftL64#, uncheckedShiftRL64#)-#endif-import GHC.Word---- | This is a workaround for poor optimisation in GHC 6.8.2. It--- fails to notice constant-width shifts, and adds a test and branch--- to every shift. This imposes about a 10% performance hit.------ These functions are undefined when the amount being shifted by is--- greater than the size in bits of a machine Int#.-class UnsafeShift a where- shiftL :: a -> Int -> a- shiftR :: a -> Int -> a--instance UnsafeShift Word16 where- {-# INLINE shiftL #-}- shiftL (W16# x#) (I# i#) = W16# (narrow16WordCompat# (word16ToWordCompat# x# `uncheckedShiftL#` i#))-- {-# INLINE shiftR #-}- shiftR (W16# x#) (I# i#) = W16# (wordToWord16Compat# (word16ToWordCompat# x# `uncheckedShiftRL#` i#))--instance UnsafeShift Word32 where- {-# INLINE shiftL #-}- shiftL (W32# x#) (I# i#) = W32# (narrow32WordCompat# (word32ToWordCompat# x# `uncheckedShiftL#` i#))-- {-# INLINE shiftR #-}- shiftR (W32# x#) (I# i#) = W32# (wordToWord32Compat# (word32ToWordCompat# x# `uncheckedShiftRL#` i#))--instance UnsafeShift Word64 where- {-# INLINE shiftL #-}- shiftL (W64# x#) (I# i#) = W64# (x# `uncheckedShiftL64#` i#)-- {-# INLINE shiftR #-}- shiftR (W64# x#) (I# i#) = W64# (x# `uncheckedShiftRL64#` i#)--instance UnsafeShift Int where- {-# INLINE shiftL #-}- shiftL (I# x#) (I# i#) = I# (x# `iShiftL#` i#)-- {-# INLINE shiftR #-}- shiftR (I# x#) (I# i#) = I# (x# `iShiftRA#` i#)--{--instance UnsafeShift Integer where- {-# INLINE shiftL #-}- shiftL = Bits.shiftL-- {-# INLINE shiftR #-}- shiftR = Bits.shiftR--}--#if MIN_VERSION_base(4,16,0)-word16ToWordCompat# :: Word16# -> Word#-word16ToWordCompat# = word16ToWord#--word32ToWordCompat# :: Word32# -> Word#-word32ToWordCompat# = word32ToWord#--wordToWord16Compat# :: Word# -> Word16#-wordToWord16Compat# = wordToWord16#--wordToWord32Compat# :: Word# -> Word32#-wordToWord32Compat# = wordToWord32#--narrow16WordCompat# :: Word# -> Word16#-narrow16WordCompat# = wordToWord16#--narrow32WordCompat# :: Word# -> Word32#-narrow32WordCompat# = wordToWord32#-#else--- No-ops-word16ToWordCompat# :: Word# -> Word#-word16ToWordCompat# x = x--word32ToWordCompat# :: Word# -> Word#-word32ToWordCompat# x = x--wordToWord16Compat# :: Word# -> Word#-wordToWord16Compat# x = x--wordToWord32Compat# :: Word# -> Word#-wordToWord32Compat# x = x---- Actual narrowing-narrow16WordCompat# :: Word# -> Word#-narrow16WordCompat# = narrow16Word#--narrow32WordCompat# :: Word# -> Word#-narrow32WordCompat# = narrow32Word#-#endif
streaming-commons.cabal view
@@ -1,5 +1,5 @@ name: streaming-commons-version: 0.2.2.2+version: 0.2.2.3 synopsis: Common lower-level functions needed by various streaming data libraries description: Provides low-dependency functionality commonly needed by various streaming data libraries, such as conduit and pipes. homepage: https://github.com/fpco/streaming-commons@@ -38,14 +38,6 @@ Data.Streaming.Zlib Data.Streaming.Zlib.Lowlevel - -- Due to cabal bugs, not making inclusion of this dependent on text version.- -- For more information, see: https://github.com/fpco/text-stream-decode/issues/1- other-modules: Data.Text.Internal.Unsafe.Char- Data.Text.Internal.Unsafe.Shift- Data.Text.Internal.Encoding.Utf8- Data.Text.Internal.Encoding.Utf16- Data.Text.Internal.Encoding.Utf32- build-depends: base >= 4.12 && < 5 , array , async@@ -55,7 +47,7 @@ , random , process , stm- , text+ , text >= 1.2 && < 1.3 || >= 2.0 && < 2.1 , transformers , zlib