Skip to content

Commit 4672a57

Browse files
authored
Deprecate D.B.getLine/hGetLine in favor of D.B.Char8 (#597)
1 parent dac5675 commit 4672a57

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Data/ByteString.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1826,8 +1826,11 @@ copy (BS x l) = unsafeCreateFp l $ \p -> memcpyFp p x l
18261826
getLine :: IO ByteString
18271827
getLine = hGetLine stdin
18281828

1829-
-- | Read a line from a handle
1829+
{-# DEPRECATED getLine
1830+
"Deprecated since @bytestring-0.12@. Use 'Data.ByteString.Char8.getLine' instead. (Functions that rely on ASCII encodings belong in \"Data.ByteString.Char8\")"
1831+
#-}
18301832

1833+
-- | Read a line from a handle
18311834
hGetLine :: Handle -> IO ByteString
18321835
hGetLine h =
18331836
wantReadableHandle_ "Data.ByteString.hGetLine" h $
@@ -1874,6 +1877,10 @@ hGetLine h =
18741877
then return r -- NB. not r+1: don't include the '\n'
18751878
else findEOL (r+1) w raw
18761879

1880+
{-# DEPRECATED hGetLine
1881+
"Deprecated since @bytestring-0.12@. Use 'Data.ByteString.Char8.hGetLine' instead. (Functions that rely on ASCII encodings belong in \"Data.ByteString.Char8\")"
1882+
#-}
1883+
18771884
mkPS :: RawBuffer Word8 -> Int -> Int -> IO ByteString
18781885
mkPS buf start end =
18791886
createFp len $ \fp -> memcpyFp fp (buf `plusForeignPtr` start) len

Data/ByteString/Char8.hs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{-# LANGUAGE MagicHash #-}
33
{-# OPTIONS_HADDOCK prune #-}
44
{-# LANGUAGE Trustworthy #-}
5+
{-# OPTIONS_GHC -Wno-deprecations #-}
56

67
-- |
78
-- Module : Data.ByteString.Char8
@@ -269,10 +270,10 @@ import Data.ByteString (null,length,tail,init,append
269270
,isInfixOf,stripPrefix,stripSuffix
270271
,breakSubstring,copy,group
271272

272-
,getLine, getContents, putStr, interact
273+
,getContents, putStr, interact
273274
,readFile, writeFile, appendFile
274275
,hGetContents, hGet, hGetSome, hPut, hPutStr
275-
,hGetLine, hGetNonBlocking, hPutNonBlocking
276+
,hGetNonBlocking, hPutNonBlocking
276277
,packCString,packCStringLen
277278
,useAsCString,useAsCStringLen
278279
)
@@ -997,6 +998,14 @@ unwords = intercalate (singleton ' ')
997998
------------------------------------------------------------------------
998999
-- For non-binary text processing:
9991000

1001+
-- | Read a line from stdin.
1002+
getLine :: IO ByteString
1003+
getLine = B.getLine
1004+
1005+
-- | Read a line from a handle
1006+
hGetLine :: Handle -> IO ByteString
1007+
hGetLine = B.hGetLine
1008+
10001009
-- | Write a ByteString to a handle, appending a newline byte.
10011010
--
10021011
-- Unlike 'hPutStr', this is not atomic: other threads might write

0 commit comments

Comments
 (0)