path-text-utf8-0.0.0.2: Read and write UTF-8 text files

Path.Text.UTF8

Contents

Description

Read and write UTF-8 text files.

Synopsis

readFile :: Path base File -> IO Text Source #

Read the contents of a UTF-8 encoded text file.

May throw IOError or UnicodeException. To handle these errors in Either instead, use tryReadFile.

Read the contents of a UTF-8 encoded text file.

Any IOError or UnicodeException that occurs is caught and returned as a ReadError on the Left side of the Either. To throw these exceptions instead, use readFile.

Constructors

Writing

writeFile :: Path base File -> Text -> IO () Source #

Write text to a file in a UTF-8 encoding.

May throw IOError. To handle this error in Either instead, use tryWriteFile.

tryWriteFile :: Path base File -> Text -> IO (Either WriteError ()) Source #

Write text to a file in a UTF-8 encoding.

Any IOError that occurs is caught and returned on the Left side of the Either. To throw the exception instead, use writeFile.

Re-exports

type IOError = IOException #

The Haskell 2010 type for exceptions in the IO monad. Any I/O operation may raise an IOError instead of returning a result. For a more general type of exception, including also those that arise in pure code, see Exception.

In Haskell 2010, this is an opaque type.

data UnicodeException :: * #

An exception type for representing Unicode encoding errors.

Constructors

 DecodeError String (Maybe Word8) Could not decode a byte sequence because it was invalid under the given encoding, or ran out of input in mid-decode.

Instances

 Methods MethodsshowList :: [UnicodeException] -> ShowS # Methods Methodsrnf :: UnicodeException -> () #