From bdb19ff51aef633e2d2afc6ceda884cbc1618cfc Mon Sep 17 00:00:00 2001 From: William Rusnack Date: Mon, 3 Jun 2024 04:48:25 -0400 Subject: [PATCH] use hPutStream for lazy hPutStr --- src/Data/Text/Lazy/IO.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Data/Text/Lazy/IO.hs b/src/Data/Text/Lazy/IO.hs index 1a24bd23..293c4323 100644 --- a/src/Data/Text/Lazy/IO.hs +++ b/src/Data/Text/Lazy/IO.hs @@ -48,8 +48,9 @@ import qualified Data.Text.Lazy as L import qualified Control.Exception as E import Control.Monad (when) import Data.IORef (readIORef) -import Data.Text.Internal.IO (hGetLineWith, readChunk) +import Data.Text.Internal.IO (hGetLineWith, readChunk, hPutStream) import Data.Text.Internal.Lazy (Text(..), chunk, empty) +import Data.Text.Internal.Lazy.Fusion (stream) import GHC.IO.Buffer (isEmptyBuffer) import GHC.IO.Exception (IOException(..), IOErrorType(..), ioException) import GHC.IO.Handle.Internals (augmentIOError, hClose_help, @@ -129,13 +130,13 @@ hGetLine = hGetLineWith L.fromChunks -- | Write a string to a handle. hPutStr :: Handle -> Text -> IO () -hPutStr h = mapM_ (T.hPutStr h) . L.toChunks +hPutStr h = hPutStream h . stream -- | Write a string to a handle, followed by a newline. hPutStrLn :: Handle -> Text -> IO () hPutStrLn h Empty = hPutChar h '\n' hPutStrLn h (Chunk t Empty) = T.hPutStrLn h t -- print the newline after the last chunk atomically -hPutStrLn h (Chunk t ts) = T.hPutStr h t >> hPutStrLn h ts +hPutStrLn h t = hPutStream h (stream t) >> hPutChar h '\n' -- | The 'interact' function takes a function of type @Text -> Text@ -- as its argument. The entire input from the standard input device is