Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated modules and functions #286

Merged
merged 4 commits into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 1 addition & 30 deletions Data/ByteString.hs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ module Data.ByteString (
getLine, -- :: IO ByteString
getContents, -- :: IO ByteString
putStr, -- :: ByteString -> IO ()
putStrLn, -- :: ByteString -> IO ()
interact, -- :: (ByteString -> ByteString) -> IO ()

-- ** Files
Expand All @@ -205,10 +204,6 @@ module Data.ByteString (
hPut, -- :: Handle -> ByteString -> IO ()
hPutNonBlocking, -- :: Handle -> ByteString -> IO ByteString
hPutStr, -- :: Handle -> ByteString -> IO ()
hPutStrLn, -- :: Handle -> ByteString -> IO ()

breakByte

) where

import qualified Prelude as P
Expand Down Expand Up @@ -1039,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.
Expand Down Expand Up @@ -1343,7 +1337,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 -> []
Expand Down Expand Up @@ -1854,33 +1848,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

Expand Down
6 changes: 0 additions & 6 deletions Data/ByteString/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ module Data.ByteString.Internal (

-- * Deprecated and unmentionable
accursedUnutterablePerformIO, -- :: IO a -> a
inlinePerformIO, -- :: IO a -> a

-- * Exported compatibility shim
plusForeignPtr
Expand Down Expand Up @@ -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
Expand Down
12 changes: 1 addition & 11 deletions Data/ByteString/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions Data/ByteString/Lazy/Builder.hs

This file was deleted.

26 changes: 0 additions & 26 deletions Data/ByteString/Lazy/Builder/ASCII.hs

This file was deleted.

11 changes: 0 additions & 11 deletions Data/ByteString/Lazy/Builder/Extras.hs

This file was deleted.

2 changes: 1 addition & 1 deletion bench/BoundsCheckFusion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 0 additions & 6 deletions bytestring.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions tests/Bench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/Hash.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 0 additions & 14 deletions tests/Properties.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
]


Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/Words.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/builder/TestSuite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
8 changes: 4 additions & 4 deletions tests/test-compare.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down