From 6debbb8323570d5aba0d57aff5724fff73d5c232 Mon Sep 17 00:00:00 2001 From: Bodigrim Date: Fri, 11 Sep 2020 18:26:42 +0100 Subject: [PATCH 1/4] Remove Data.ByteString.Lazy.Builder --- Data/ByteString/Lazy/Builder.hs | 11 ----------- Data/ByteString/Lazy/Builder/ASCII.hs | 26 -------------------------- Data/ByteString/Lazy/Builder/Extras.hs | 11 ----------- bench/BoundsCheckFusion.hs | 2 +- bytestring.cabal | 6 ------ tests/builder/TestSuite.hs | 2 +- 6 files changed, 2 insertions(+), 56 deletions(-) delete mode 100644 Data/ByteString/Lazy/Builder.hs delete mode 100644 Data/ByteString/Lazy/Builder/ASCII.hs delete mode 100644 Data/ByteString/Lazy/Builder/Extras.hs diff --git a/Data/ByteString/Lazy/Builder.hs b/Data/ByteString/Lazy/Builder.hs deleted file mode 100644 index b4c32dfdd..000000000 --- a/Data/ByteString/Lazy/Builder.hs +++ /dev/null @@ -1,11 +0,0 @@ - --- | We decided to rename the Builder modules. Sorry about that. --- --- The old names will hang about for at least once release cycle and then later remove them. --- -module Data.ByteString.Lazy.Builder - {-# DEPRECATED "Use Data.ByteString.Builder instead" #-} ( - module Data.ByteString.Builder -) where - -import Data.ByteString.Builder diff --git a/Data/ByteString/Lazy/Builder/ASCII.hs b/Data/ByteString/Lazy/Builder/ASCII.hs deleted file mode 100644 index 91260623b..000000000 --- a/Data/ByteString/Lazy/Builder/ASCII.hs +++ /dev/null @@ -1,26 +0,0 @@ - --- | We decided to rename the Builder modules. Sorry about that. --- --- In additon, the ASCII module has been merged into the main --- "Data.ByteString.Builder" module. --- --- The old names will hang about for at least once release cycle and then later remove them. --- -module Data.ByteString.Lazy.Builder.ASCII - {-# DEPRECATED "Use Data.ByteString.Builder instead" #-} ( - module Data.ByteString.Builder -, byteStringHexFixed -, lazyByteStringHexFixed -) where - -import Data.ByteString.Builder -import qualified Data.ByteString as S -import qualified Data.ByteString.Lazy as L - -byteStringHexFixed :: S.ByteString -> Builder -byteStringHexFixed = byteStringHex -{-# DEPRECATED byteStringHexFixed "Use byteStringHex instead" #-} - -lazyByteStringHexFixed :: L.ByteString -> Builder -lazyByteStringHexFixed = lazyByteStringHex -{-# DEPRECATED lazyByteStringHexFixed "Use lazyByteStringHex instead" #-} \ No newline at end of file diff --git a/Data/ByteString/Lazy/Builder/Extras.hs b/Data/ByteString/Lazy/Builder/Extras.hs deleted file mode 100644 index bf7eafb37..000000000 --- a/Data/ByteString/Lazy/Builder/Extras.hs +++ /dev/null @@ -1,11 +0,0 @@ - --- | We decided to rename the Builder modules. Sorry about that. --- --- The old names will hang about for at least once release cycle and then later remove them. --- -module Data.ByteString.Lazy.Builder.Extras - {-# DEPRECATED "Use Data.ByteString.Builder.Extra instead" #-} ( - module Data.ByteString.Builder.Extra -) where - -import Data.ByteString.Builder.Extra diff --git a/bench/BoundsCheckFusion.hs b/bench/BoundsCheckFusion.hs index e6e441e9b..0386675fd 100644 --- a/bench/BoundsCheckFusion.hs +++ b/bench/BoundsCheckFusion.hs @@ -81,7 +81,7 @@ main = do mapM_ putStrLn sanityCheckInfo putStrLn "" Gauge.defaultMain - [ bgroup "Data.ByteString.Lazy.Builder" + [ bgroup "Data.ByteString.Builder" [ -- benchBInts "foldMap intHost" $ -- foldMap (intHost . fromIntegral) diff --git a/bytestring.cabal b/bytestring.cabal index d7cae1517..5be0be0cd 100644 --- a/bytestring.cabal +++ b/bytestring.cabal @@ -89,12 +89,6 @@ library -- perhaps only exposed temporarily Data.ByteString.Builder.Internal Data.ByteString.Builder.Prim.Internal - - -- sigh, we decided to rename shortly after making - -- an initial release, so these are here for compat - Data.ByteString.Lazy.Builder - Data.ByteString.Lazy.Builder.Extras - Data.ByteString.Lazy.Builder.ASCII other-modules: Data.ByteString.Builder.ASCII Data.ByteString.Builder.Prim.Binary diff --git a/tests/builder/TestSuite.hs b/tests/builder/TestSuite.hs index 2c76fbd3d..212ff1de6 100644 --- a/tests/builder/TestSuite.hs +++ b/tests/builder/TestSuite.hs @@ -17,6 +17,6 @@ tests = [ testGroup "Data.ByteString.Builder" Data.ByteString.Builder.Tests.tests - , testGroup "Data.ByteString.Lazy.Builder.BasicEncoding" + , testGroup "Data.ByteString.Builder.BasicEncoding" Data.ByteString.Builder.Prim.Tests.tests ] From f4c301edae1e3003184277eabca21b15c5b7946a Mon Sep 17 00:00:00 2001 From: Bodigrim Date: Fri, 11 Sep 2020 18:28:08 +0100 Subject: [PATCH 2/4] Remove putStrLn and hPutStrLn from Word8 modules --- Data/ByteString.hs | 27 +-------------------------- Data/ByteString/Lazy.hs | 12 +----------- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/Data/ByteString.hs b/Data/ByteString.hs index 09d0b6f97..f41b3e9e5 100644 --- a/Data/ByteString.hs +++ b/Data/ByteString.hs @@ -188,7 +188,6 @@ module Data.ByteString ( getLine, -- :: IO ByteString getContents, -- :: IO ByteString putStr, -- :: ByteString -> IO () - putStrLn, -- :: ByteString -> IO () interact, -- :: (ByteString -> ByteString) -> IO () -- ** Files @@ -205,7 +204,6 @@ module Data.ByteString ( hPut, -- :: Handle -> ByteString -> IO () hPutNonBlocking, -- :: Handle -> ByteString -> IO ByteString hPutStr, -- :: Handle -> ByteString -> IO () - hPutStrLn, -- :: Handle -> ByteString -> IO () breakByte @@ -1343,7 +1341,7 @@ findIndices :: (Word8 -> Bool) -> ByteString -> [Int] findIndices p ps = loop 0 ps where loop !n !qs = case findIndex p qs of - Just !i -> + Just !i -> let !j = n+i in j : loop (j+1) (unsafeDrop (i+1) qs) Nothing -> [] @@ -1854,33 +1852,10 @@ hPutNonBlocking h bs@(BS ps l) = do hPutStr :: Handle -> ByteString -> IO () hPutStr = hPut --- | Write a ByteString to a handle, appending a newline byte. --- --- Unlike 'hPutStr', this is not atomic: other threads might write --- to the handle between writing of the bytestring and the newline. -hPutStrLn :: Handle -> ByteString -> IO () -hPutStrLn h ps - | length ps < 1024 = hPut h (ps `snoc` 0x0a) - | otherwise = hPut h ps >> hPut h (singleton (0x0a)) -- don't copy - -- | Write a ByteString to stdout putStr :: ByteString -> IO () putStr = hPut stdout --- | Write a ByteString to stdout, appending a newline byte. --- --- Unlike 'putStr', this is not atomic: other threads might write --- to stdout between writing of the bytestring and the newline. -putStrLn :: ByteString -> IO () -putStrLn = hPutStrLn stdout - -{-# DEPRECATED hPutStrLn - "Use Data.ByteString.Char8.hPutStrLn instead. (Functions that rely on ASCII encodings belong in Data.ByteString.Char8)" - #-} -{-# DEPRECATED putStrLn - "Use Data.ByteString.Char8.putStrLn instead. (Functions that rely on ASCII encodings belong in Data.ByteString.Char8)" - #-} - ------------------------------------------------------------------------ -- Low level IO diff --git a/Data/ByteString/Lazy.hs b/Data/ByteString/Lazy.hs index 6c4a1c173..152266cce 100644 --- a/Data/ByteString/Lazy.hs +++ b/Data/ByteString/Lazy.hs @@ -194,7 +194,6 @@ module Data.ByteString.Lazy ( -- ** Standard input and output getContents, -- :: IO ByteString putStr, -- :: ByteString -> IO () - putStrLn, -- :: ByteString -> IO () interact, -- :: (ByteString -> ByteString) -> IO () -- ** Files @@ -1381,15 +1380,6 @@ hPutStr = hPut putStr :: ByteString -> IO () putStr = hPut stdout --- | Write a ByteString to stdout, appending a newline byte --- -putStrLn :: ByteString -> IO () -putStrLn ps = hPut stdout ps >> hPut stdout (singleton 0x0a) - -{-# DEPRECATED putStrLn - "Use Data.ByteString.Lazy.Char8.putStrLn instead. (Functions that rely on ASCII encodings belong in Data.ByteString.Lazy.Char8)" - #-} - -- | The interact function takes a function of type @ByteString -> ByteString@ -- as its argument. The entire input from the standard input device is passed -- to this function as its argument, and the resulting string is output on the @@ -1455,7 +1445,7 @@ findIndexOrEnd k (S.BS x l) = -- > _ <- BL.readFile "foo.txt" -- > BL.writeFile "foo.txt" mempty -- --- Generally, in the 'IO' monad side effects happen +-- Generally, in the 'IO' monad side effects happen -- sequentially and in full. Therefore, one might reasonably expect that -- reading the whole file via 'readFile' executes all three actions -- (open the file handle, read its content, close the file handle) before From 141b398ed62bc8ee4eff22ed84566431aa9b002c Mon Sep 17 00:00:00 2001 From: Bodigrim Date: Fri, 11 Sep 2020 18:28:40 +0100 Subject: [PATCH 3/4] Remove breakByte --- Data/ByteString.hs | 4 ---- tests/Bench.hs | 8 -------- tests/Properties.hs | 14 -------------- 3 files changed, 26 deletions(-) diff --git a/Data/ByteString.hs b/Data/ByteString.hs index f41b3e9e5..3c1548a35 100644 --- a/Data/ByteString.hs +++ b/Data/ByteString.hs @@ -204,9 +204,6 @@ module Data.ByteString ( hPut, -- :: Handle -> ByteString -> IO () hPutNonBlocking, -- :: Handle -> ByteString -> IO ByteString hPutStr, -- :: Handle -> ByteString -> IO () - - breakByte - ) where import qualified Prelude as P @@ -1037,7 +1034,6 @@ breakByte c p = case elemIndex c p of Nothing -> (p,empty) Just n -> (unsafeTake n p, unsafeDrop n p) {-# INLINE breakByte #-} -{-# DEPRECATED breakByte "It is an internal function and should never have been exported. Use 'break (== x)' instead. (There are rewrite rules that handle this special case of 'break'.)" #-} -- | Returns the longest (possibly empty) suffix of elements which __do not__ -- satisfy the predicate and the remainder of the string. diff --git a/tests/Bench.hs b/tests/Bench.hs index d6dc7aeeb..0e67c4348 100644 --- a/tests/Bench.hs +++ b/tests/Bench.hs @@ -131,14 +131,6 @@ tests = [F ({-# SCC "split" #-} app $ B.split 0x0a) ,F ({-# SCC "lazy split" #-} app $ L.split 0x0a) ]) --- , ("breakByte", --- [F ({-# SCC "breakChar" #-} app $ B.breakByte 122) --- ,F ({-# SCC "lazy breakChar" #-} app $ L.breakByte 122) --- ]) --- , ("spanByte", --- [F ({-# SCC "spanChar" #-} app $ B.spanByte 122) --- ,F ({-# SCC "lazy spanChar" #-} app $ L.spanByte 122) --- ]) , ("reverse", [F ({-# SCC "reverse" #-} app B.reverse) ,F ({-# SCC "lazy reverse" #-} app L.reverse) diff --git a/tests/Properties.hs b/tests/Properties.hs index 58fa16810..bb1fdfa0a 100644 --- a/tests/Properties.hs +++ b/tests/Properties.hs @@ -734,10 +734,6 @@ prop_breakspan xs c = L.break (==c) xs == L.span (/=c) xs prop_span xs a = (span (/=a) xs) == (let (x,y) = L.span (/=a) (pack xs) in (unpack x, unpack y)) --- prop_breakByte xs c = L.break (== c) xs == L.breakByte c xs - --- prop_spanByte c xs = (L.span (==c) xs) == L.spanByte c xs - prop_split c xs = (map L.unpack . map checkInvariant . L.split c $ xs) == (map P.unpack . P.split c . P.pack . L.unpack $ xs) @@ -1366,12 +1362,6 @@ prop_unzipBB x = let (xs,ys) = unzip x in (P.pack xs, P.pack ys) == P.unzip x -- prop_join_spec c s1 s2 = -- P.join (P.singleton c) (s1 : s2 : []) == P.joinWithByte c s1 s2 --- prop_break_spec x s = --- P.break ((==) x) s == P.breakByte x s - --- prop_span_spec x s = --- P.span ((==) x) s == P.spanByte x s - ------------------------------------------------------------------------ -- Test IsString, Show, Read, pack, unpack @@ -2347,8 +2337,6 @@ bb_tests = , testProperty "unzip" prop_unzipBB , testProperty "concatMap" prop_concatMapBB -- , testProperty "join/joinByte" prop_join_spec --- , testProperty "span/spanByte" prop_span_spec --- , testProperty "break/breakByte"prop_break_spec ] @@ -2429,8 +2417,6 @@ ll_tests = , testProperty "span" prop_span , testProperty "splitAt" prop_splitAt , testProperty "break/span" prop_breakspan --- , testProperty "break/breakByte" prop_breakByte --- , testProperty "span/spanByte" prop_spanByte , testProperty "split" prop_split , testProperty "splitWith_empty" prop_splitWith_empty , testProperty "splitWith" prop_splitWith From 4bcdefa04d1fb6b0643d346917746afa40129508 Mon Sep 17 00:00:00 2001 From: Bodigrim Date: Fri, 11 Sep 2020 18:29:00 +0100 Subject: [PATCH 4/4] Remove inlinePerformIO --- Data/ByteString/Internal.hs | 6 ------ tests/Hash.hs | 2 +- tests/Words.hs | 6 +++--- tests/test-compare.hs | 8 ++++---- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Data/ByteString/Internal.hs b/Data/ByteString/Internal.hs index f4c98eaac..31405dd02 100644 --- a/Data/ByteString/Internal.hs +++ b/Data/ByteString/Internal.hs @@ -87,7 +87,6 @@ module Data.ByteString.Internal ( -- * Deprecated and unmentionable accursedUnutterablePerformIO, -- :: IO a -> a - inlinePerformIO, -- :: IO a -> a -- * Exported compatibility shim plusForeignPtr @@ -719,11 +718,6 @@ overflowError fun = error $ "Data.ByteString." ++ fun ++ ": size overflow" accursedUnutterablePerformIO :: IO a -> a accursedUnutterablePerformIO (IO m) = case m realWorld# of (# _, r #) -> r -inlinePerformIO :: IO a -> a -inlinePerformIO = accursedUnutterablePerformIO -{-# INLINE inlinePerformIO #-} -{-# DEPRECATED inlinePerformIO "If you think you know what you are doing, use 'System.IO.Unsafe.unsafePerformIO'. If you are sure you know what you are doing, use 'unsafeDupablePerformIO'. If you enjoy sharing an address space with a malevolent agent of chaos, try 'accursedUnutterablePerformIO'." #-} - -- --------------------------------------------------------------------- -- -- Standard C functions diff --git a/tests/Hash.hs b/tests/Hash.hs index 9629917c0..dbb633a2e 100644 --- a/tests/Hash.hs +++ b/tests/Hash.hs @@ -69,7 +69,7 @@ eq a@(S.BS p l) b@(S.BS p' l') | p == p' = True -- short cut for the same string | otherwise = compare a b == EQ where - compare (S.BS fp1 len1) (S.BS fp2 len2) = S.inlinePerformIO $ + compare (S.BS fp1 len1) (S.BS fp2 len2) = S.accursedUnutterablePerformIO $ withForeignPtr fp1 $ \p1 -> withForeignPtr fp2 $ \p2 -> cmp p1 p2 0 len1 len2 diff --git a/tests/Words.hs b/tests/Words.hs index 03db7b298..2aec7cb9c 100644 --- a/tests/Words.hs +++ b/tests/Words.hs @@ -38,8 +38,8 @@ compareBytes :: ByteString -> ByteString -> Ordering compareBytes (BS fp1 len1) (BS fp2 len2) | len1 == 0 && len2 == 0 = EQ -- short cut for empty strings | fp1 == fp2 && len1 == len2 = EQ -- short cut for the same string --- | max len1 len2 > 1 = inlinePerformIO $ - | otherwise = inlinePerformIO $ +-- | max len1 len2 > 1 = accursedUnutterablePerformIO $ + | otherwise = accursedUnutterablePerformIO $ withForeignPtr fp1 $ \p1 -> withForeignPtr fp2 $ \p2 -> do i <- memcmp p1 p2 (fromIntegral $ min len1 len2) @@ -49,7 +49,7 @@ compareBytes (BS fp1 len1) (BS fp2 len2) {- - | otherwise = inlinePerformIO $ + | otherwise = accursedUnutterablePerformIO $ withForeignPtr fp1 $ \p1 -> withForeignPtr fp2 $ \p2 -> cmp (p1 `plusPtr` off1) diff --git a/tests/test-compare.hs b/tests/test-compare.hs index cec7adf62..19725f696 100644 --- a/tests/test-compare.hs +++ b/tests/test-compare.hs @@ -40,11 +40,11 @@ compareBytes :: ByteString -> ByteString -> Ordering compareBytes (BS fp1 len1) (BS fp2 len2) -- | len1 == 0 && len2 == 0 = EQ -- short cut for empty strings -- | fp1 == fp2 && len1 == len2 = EQ -- short cut for the same string - | otherwise = inlinePerformIO $ + | otherwise = accursedUnutterablePerformIO $ withForeignPtr fp1 $ \p1 -> withForeignPtr fp2 $ \p2 -> cmp p1 p2 0 len1 len2 - + cmp :: Ptr Word8 -> Ptr Word8 -> Int -> Int -> Int-> IO Ordering cmp p1 p2 n len1 len2 | n == len1 = if n == len2 then return EQ else return LT @@ -56,11 +56,11 @@ cmp p1 p2 n len1 len2 EQ -> cmp p1 p2 (n+1) len1 len2 LT -> return LT GT -> return GT - + compareBytesC (BS x1 l1) (BS x2 l2) | l1 == 0 && l2 == 0 = EQ -- short cut for empty strings | x1 == x2 && l1 == l2 = EQ -- short cut for the same string - | otherwise = inlinePerformIO $ + | otherwise = accursedUnutterablePerformIO $ withForeignPtr x1 $ \p1 -> withForeignPtr x2 $ \p2 -> do i <- memcmp p1 p2 (fromIntegral $ min l1 l2)