W3cubDocs

/Haskell 9

Data.Text.IO.Utf8

License BSD-style
Portability GHC
Safe Haskell Safe-Inferred
Language Haskell2010

Description

Efficient UTF-8 support for text I/O. Unlike Data.Text.IO, these functions do not depend on the locale and do not do line ending conversion.

File-at-a-time operations

readFile :: FilePath -> IO Text Source

The readFile function reads a file and returns the contents of the file as a string. The entire file is read strictly, as with getContents.

writeFile :: FilePath -> Text -> IO () Source

Write a string to a file. The file is truncated to zero length before writing begins.

appendFile :: FilePath -> Text -> IO () Source

Write a string to the end of a file.

Operations on handles

hGetContents :: Handle -> IO Text Source

Read the remaining contents of a Handle as a string.

hGetLine :: Handle -> IO Text Source

Read a single line from a handle.

hPutStr :: Handle -> Text -> IO () Source

Write a string to a handle.

hPutStrLn :: Handle -> Text -> IO () Source

Write a string to a handle, followed by a newline.

Special cases for standard input and output

interact :: (Text -> Text) -> IO () Source

The interact function takes a function of type Text -> Text as its argument. The entire input from the standard input device is passed to this function as its argument, and the resulting string is output on the standard output device.

getContents :: IO Text Source

Read all user input on stdin as a single string.

getLine :: IO Text Source

Read a single line of user input from stdin.

putStr :: Text -> IO () Source

Write a string to stdout.

putStrLn :: Text -> IO () Source

Write a string to stdout, followed by a newline.

© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/9.12.1/docs/libraries/text-2.1.2-84f9/Data-Text-IO-Utf8.html