module Data.Text.IO where import qualified Data.ByteString as BS import Data.Text as T import Data.Text.Private import System.IO (Handle, stdin, stdout) put, putLn :: Text -> IO () put = hPut stdout putLn = hPutLn stdout getContents :: IO Text getContents = hGetContents stdin hGet :: Handle -> Int -> IO Text hGet h n = Text <$> BS.hGet h n hGetContents :: Handle -> IO Text hGetContents h = Text <$> BS.hGetContents h hPut, hPutLn :: Handle -> Text -> IO () hPut h = BS.hPut h . unText hPutLn h t | T.length t < 0x400 = hPut h (t `snoc` '\n') | otherwise = hPut h t *> hPut h "\n" hPutNonBlocking :: Handle -> Text -> IO Text hPutNonBlocking h = fmap Text . BS.hPutNonBlocking h . unText