-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Read and write UTF-8 text files
--
-- This is a trivial integration of the path and text
-- packages, providing convenient functions to read and write UTF-8 text
-- files.
@package path-text-utf8
@version 0.0.0.2
-- | Read and write UTF-8 text files.
module Path.Text.UTF8
-- | Read the contents of a UTF-8 encoded text file.
--
-- May throw IOError or UnicodeException. To handle these
-- errors in Either instead, use tryReadFile.
readFile :: Path base File -> IO Text
-- | 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.
tryReadFile :: Path base File -> IO (Either ReadError Text)
data ReadError
ReadErrorIO :: IOError -> ReadError
ReadErrorDecode :: UnicodeException -> ReadError
-- | Write text to a file in a UTF-8 encoding.
--
-- May throw IOError. To handle this error in Either
-- instead, use tryWriteFile.
writeFile :: Path base File -> Text -> IO ()
-- | 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.
tryWriteFile :: Path base File -> Text -> IO (Either WriteError ())
type WriteError = IOError
-- | 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.
type IOError = IOException
-- | An exception type for representing Unicode encoding errors.
data UnicodeException :: *
-- | Could not decode a byte sequence because it was invalid under the
-- given encoding, or ran out of input in mid-decode.
DecodeError :: String -> Maybe Word8 -> UnicodeException