@@ -13,8 +13,8 @@
13module Data.Text.IO.Internal
13module Data.Text.IO.Internal
15#if __GLASGOW_HASKELL__ >= 612
15#if __GLASGOW_HASKELL__ >= 612
16− hGetLineLoop
16+ getSomeCharacters
17− , getSomeCharacters
17+ , hGetLineWith
19 , unpack_nl
19 , unpack_nl
@@ -23,7 +23,6 @@ module Data.Text.IO.Internal
23#if __GLASGOW_HASKELL__ >= 612
23#if __GLASGOW_HASKELL__ >= 612
24import Control.Exception (throw)
24import Control.Exception (throw)
25import Data.IORef (readIORef, writeIORef)
25import Data.IORef (readIORef, writeIORef)
26−import qualified Data.Text as T
27import Data.Text (Text)
26import Data.Text (Text)
28import Data.Text.Fusion (stream, unstream)
27import Data.Text.Fusion (stream, unstream)
29import Data.Text.Fusion.Internal (Step(..), Stream(..))
28import Data.Text.Fusion.Internal (Step(..), Stream(..))
@@ -40,7 +39,16 @@ import GHC.IO.Handle.Internals (augmentIOError, ioe_EOF, readTextDevice,
40import GHC.IO.Handle.Text (commitBuffer')
39import GHC.IO.Handle.Text (commitBuffer')
41import GHC.IO.Handle.Types (BufferList(..), BufferMode(..), Handle__(..),
40import GHC.IO.Handle.Types (BufferList(..), BufferMode(..), Handle__(..),
42 Newline(..))
41 Newline(..))
42+import System.IO (Handle)
43import System.IO.Error (isEOFError)
43import System.IO.Error (isEOFError)
44+import qualified Data.Text as T
46+hGetLineWith :: ([Text] -> t) -> Handle -> IO t
47+hGetLineWith f h = wantReadableHandle_ "hGetLine" h go
48+ where go hh@Handle__{..} = do
49+ buf <- readIORef haCharBuffer
50+ ts <- hGetLineLoop hh [] buf
45hGetLineLoop :: Handle__ -> [Text] -> CharBuffer -> IO [Text]
53hGetLineLoop :: Handle__ -> [Text] -> CharBuffer -> IO [Text]
46hGetLineLoop hh@Handle__{..} ts buf@Buffer{ bufL=r0, bufR=w, bufRaw=raw0 } = do
54hGetLineLoop hh@Handle__{..} ts buf@Buffer{ bufL=r0, bufR=w, bufRaw=raw0 } = do