@@ -46,10 +46,6 @@ import Prelude hiding (appendFile, getContents, getLine, interact,
46 putStr, putStrLn, readFile, writeFile)
46 putStr, putStrLn, readFile, writeFile)
47import System.IO (Handle, IOMode(..), hPutChar, openFile, stdin, stdout,
47import System.IO (Handle, IOMode(..), hPutChar, openFile, stdin, stdout,
49−#if __GLASGOW_HASKELL__ <= 610
50−import qualified Data.ByteString.Char8 as B
51−import Data.Text.Encoding (decodeUtf8, encodeUtf8)
53import qualified Control.Exception as E
49import qualified Control.Exception as E
54import Control.Monad (liftM2, when)
50import Control.Monad (liftM2, when)
55import Data.IORef (readIORef, writeIORef)
51import Data.IORef (readIORef, writeIORef)
@@ -68,7 +64,6 @@ import GHC.IO.Handle.Types (BufferList(..), BufferMode(..), Handle__(..),
68 HandleType(..), Newline(..))
64 HandleType(..), Newline(..))
69import System.IO (hGetBuffering, hFileSize, hSetBuffering, hTell)
65import System.IO (hGetBuffering, hFileSize, hSetBuffering, hTell)
70import System.IO.Error (isEOFError)
66import System.IO.Error (isEOFError)
73-- $performance
68-- $performance
74-- #performance#
69-- #performance#
@@ -137,9 +132,6 @@ hGetChunk h = wantReadableHandle "hGetChunk" h readSingleChunk
137-- result to construct its result. For files more than a half of
132-- result to construct its result. For files more than a half of
138-- available RAM in size, this may result in memory exhaustion.
133-- available RAM in size, this may result in memory exhaustion.
139hGetContents :: Handle -> IO Text
134hGetContents :: Handle -> IO Text
140−#if __GLASGOW_HASKELL__ <= 610
141−hGetContents = fmap decodeUtf8 . B.hGetContents
143hGetContents h = do
135hGetContents h = do
144 chooseGoodBuffering h
136 chooseGoodBuffering h
145 wantReadableHandle "hGetContents" h readAll
137 wantReadableHandle "hGetContents" h readAll
@@ -171,21 +163,13 @@ chooseGoodBuffering h = do
171 else E.throwIO e
163 else E.throwIO e
172 when (d > 0) . hSetBuffering h . BlockBuffering . Just . fromIntegral $ d
164 when (d > 0) . hSetBuffering h . BlockBuffering . Just . fromIntegral $ d
173 _ -> return ()
165 _ -> return ()
176-- | Read a single line from a handle.
167-- | Read a single line from a handle.
177hGetLine :: Handle -> IO Text
168hGetLine :: Handle -> IO Text
178−#if __GLASGOW_HASKELL__ <= 610
179−hGetLine = fmap decodeUtf8 . B.hGetLine
181hGetLine = hGetLineWith T.concat
169hGetLine = hGetLineWith T.concat
184-- | Write a string to a handle.
171-- | Write a string to a handle.
185hPutStr :: Handle -> Text -> IO ()
172hPutStr :: Handle -> Text -> IO ()
186−#if __GLASGOW_HASKELL__ <= 610
187−hPutStr h = B.hPutStr h . encodeUtf8
189-- This function is lifted almost verbatim from GHC.IO.Handle.Text.
173-- This function is lifted almost verbatim from GHC.IO.Handle.Text.
190hPutStr h t = do
174hPutStr h t = do
191 (buffer_mode, nl) <-
175 (buffer_mode, nl) <-
@@ -295,7 +279,6 @@ commitBuffer hdl !raw !sz !count flush release =
295 wantWritableHandle "commitAndReleaseBuffer" hdl $
279 wantWritableHandle "commitAndReleaseBuffer" hdl $
296 commitBuffer' raw sz count flush release
280 commitBuffer' raw sz count flush release
297{-# INLINE commitBuffer #-}
281{-# INLINE commitBuffer #-}
300-- | Write a string to a handle, followed by a newline.
283-- | Write a string to a handle, followed by a newline.
301hPutStrLn :: Handle -> Text -> IO ()
284hPutStrLn :: Handle -> Text -> IO ()