[commit: bytestring] ghc-7.6: Document for the Char8 I/O that it does not respect the newline mode (0c1a318)
Paolo Capriotti
p.capriotti at gmail.com
Thu Sep 6 12:29:08 CEST 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/bytestring
On branch : ghc-7.6
http://hackage.haskell.org/trac/ghc/changeset/0c1a318495026f36512c927f936c75758808926d
>---------------------------------------------------------------
commit 0c1a318495026f36512c927f936c75758808926d
Author: Duncan Coutts <duncan at community.haskell.org>
Date: Wed Sep 5 19:59:19 2012 +0000
Document for the Char8 I/O that it does not respect the newline mode
though that this is considered a flaw and may be changed in future.
>---------------------------------------------------------------
Data/ByteString.hs | 3 +--
Data/ByteString/Char8.hs | 3 +++
Data/ByteString/Lazy/Char8.hs | 6 ++++--
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/Data/ByteString.hs b/Data/ByteString.hs
index 21630f3..12c97e8 100644
--- a/Data/ByteString.hs
+++ b/Data/ByteString.hs
@@ -1968,8 +1968,7 @@ interact transformer = putStr . transformer =<< getContents
-- | 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. Files are read using 'binary mode' on Windows,
--- for 'text mode' use the Char8 version of this function.
+-- reading it using 'hGet'.
--
readFile :: FilePath -> IO ByteString
readFile f = bracket (openBinaryFile f ReadMode) hClose
diff --git a/Data/ByteString/Char8.hs b/Data/ByteString/Char8.hs
index b3117bc..6bad28e 100644
--- a/Data/ByteString/Char8.hs
+++ b/Data/ByteString/Char8.hs
@@ -193,6 +193,9 @@ module Data.ByteString.Char8 (
useAsCStringLen, -- :: ByteString -> (CStringLen -> IO a) -> IO a
-- * I\/O with 'ByteString's
+ -- | ByteString I/O uses binary mode, without any character decoding
+ -- or newline conversion. The fact that it does not respect the Handle
+ -- newline mode is considered a flaw and may be changed in a future version.
-- ** Standard input and output
getLine, -- :: IO ByteString
diff --git a/Data/ByteString/Lazy/Char8.hs b/Data/ByteString/Lazy/Char8.hs
index 840b50a..279902d 100644
--- a/Data/ByteString/Lazy/Char8.hs
+++ b/Data/ByteString/Lazy/Char8.hs
@@ -167,6 +167,9 @@ module Data.ByteString.Lazy.Char8 (
readInteger,
-- * I\/O with 'ByteString's
+ -- | ByteString I/O uses binary mode, without any character decoding
+ -- or newline conversion. The fact that it does not respect the Handle
+ -- newline mode is considered a flaw and may be changed in a future version.
-- ** Standard input and output
getContents, -- :: IO ByteString
@@ -853,8 +856,7 @@ readInteger (Chunk c0 cs0) =
end n c cs = let c' = chunk c cs
in c' `seq` (n, c')
--- | Read an entire file /lazily/ into a 'ByteString'. Use 'text mode'
--- on Windows to interpret newlines
+-- | Read an entire file /lazily/ into a 'ByteString'.
readFile :: FilePath -> IO ByteString
readFile f = openBinaryFile f ReadMode >>= hGetContents
More information about the Cvs-libraries
mailing list