[commit: packages/bytestring] master: Data.ByteString.Char8 uses IO functions exported from Data.ByteString (2fba115)

git at git.haskell.org git at git.haskell.org
Mon Apr 17 21:31:35 UTC 2017


Repository : ssh://git@git.haskell.org/bytestring

On branch  : master
Link       : http://git.haskell.org/packages/bytestring.git/commitdiff/2fba115881b2da32ce076c1114ad6fe8d893086b

>---------------------------------------------------------------

commit 2fba115881b2da32ce076c1114ad6fe8d893086b
Author: Travis Whitaker <pi.boy.travis at gmail.com>
Date:   Tue Sep 20 17:09:59 2016 -0400

    Data.ByteString.Char8 uses IO functions exported from Data.ByteString


>---------------------------------------------------------------

2fba115881b2da32ce076c1114ad6fe8d893086b
 Data/ByteString/Char8.hs | 38 +++-----------------------------------
 1 file changed, 3 insertions(+), 35 deletions(-)

diff --git a/Data/ByteString/Char8.hs b/Data/ByteString/Char8.hs
index 5959c75..f548a5e 100644
--- a/Data/ByteString/Char8.hs
+++ b/Data/ByteString/Char8.hs
@@ -248,9 +248,10 @@ import Data.ByteString (empty,null,length,tail,init,append
                        ,findSubstring,findSubstrings,breakSubstring,copy,group
 
                        ,getLine, getContents, putStr, interact
+                       ,readFile, writeFile, appendFile
                        ,hGetContents, hGet, hGetSome, hPut, hPutStr
-                       ,hGetLine, hGetNonBlocking, hPutNonBlocking
-                       ,packCString,packCStringLen
+                       ,hPutStrLn, putStrLn, hGetLine, hGetNonBlocking
+                       ,hPutNonBlocking, packCString, packCStringLen
                        ,useAsCString,useAsCStringLen
                        )
 
@@ -263,7 +264,6 @@ import GHC.Char (eqChar)
 #endif
 import qualified Data.List as List (intersperse)
 
-import System.IO    (Handle,stdout,withBinaryFile,hFileSize,IOMode(..))
 import Foreign
 
 
@@ -963,35 +963,3 @@ readInteger as
 
           combine2 b (n:m:ns) = let t = m*b + n in t `seq` (t : combine2 b ns)
           combine2 _ ns       = ns
-
-------------------------------------------------------------------------
--- For non-binary text processing:
-
--- | Read an entire file strictly into a 'ByteString'.  This is far more
--- efficient than reading the characters into a 'String' and then using
--- 'pack'.  It also may be more efficient than opening the file and
--- reading it using hGet.
-readFile :: FilePath -> IO ByteString
-readFile f = withBinaryFile f ReadMode
-    (\h -> hFileSize h >>= hGet h . fromIntegral)
-
-modifyFile :: IOMode -> FilePath -> ByteString -> IO ()
-modifyFile mode f txt = withBinaryFile f mode (`hPut` txt)
-
--- | Write a 'ByteString' to a file.
-writeFile :: FilePath -> ByteString -> IO ()
-writeFile = modifyFile WriteMode
-
--- | Append a 'ByteString' to a file.
-appendFile :: FilePath -> ByteString -> IO ()
-appendFile = modifyFile AppendMode
-
--- | Write a ByteString to a handle, appending a newline byte
-hPutStrLn :: Handle -> ByteString -> IO ()
-hPutStrLn h ps
-    | length ps < 1024 = hPut h (ps `B.snoc` 0x0a)
-    | otherwise        = hPut h ps >> hPut h (B.singleton 0x0a) -- don't copy
-
--- | Write a ByteString to stdout, appending a newline byte
-putStrLn :: ByteString -> IO ()
-putStrLn = hPutStrLn stdout



More information about the ghc-commits mailing list