> interface PreludeWriteTextIO where > import PreludeMonadicIO > import PreludeIOError > import PreludeStdIO
> putChar :: Char -> IO () > hPutChar :: Handle -> Char -> IO () > putChar = hPutChar stdout
Computation hPutChar
hdl c writes the
character c to the file or channel managed by hdl.
Characters may be buffered if buffering is enabled for hdl.
The computation may fail with:
HardwareFault
EIO
]
ResourceExhausted
ENOMEM
, ENOSPC
]
ResourceVanished
EPIPE
]
PermissionDenied
EFBIG
]
IllegalOperation
> putStr :: String -> IO () > hPutStr :: Handle -> String -> IO () > putText :: Text a => a -> IO () > hPutText :: Text a => Handle -> a -> IO () > print :: Text a => a -> IO () > putStr = hPutStr stdout > hPutStr hdl = foldr (>>) (return ()) . map (hPutChar hdl) > putText = hPutText stdout > hPutText hdl = hPutStr hdl . show > print x = putText x >> putChar '\n'
Computation hPutStr
hdl s writes the string
s to the file or channel managed by hdl.
The computation may fail with:
HardwareFault
EIO
]
ResourceExhausted
ENOMEM
, ENOSPC
]
ResourceVanished
EPIPE
]
PermissionDenied
EFBIG
]
IllegalOperation
Computation putStr
s writes the string
s to stdout
.
The computation may fail with the same errors as hPutChar
.
Computation hPutText
hdl t writes the string
representation of t given by the shows
function
to the file or channel managed by hdl.
The computation may fail with the same errors as hPutStr
.
> writeFile :: FilePath -> String -> IO () > appendFile :: FilePath -> String -> IO () > writeFile name str = > openFile name WriteMode >>= \hdl -> hPutStr hdl str >> hClose hdl > appendFile name str = > openFile name AppendMode >>= \hdl -> hPutStr hdl str >> hClose hdl
writeFile
file
s replaces the contents of file by the string
s.
appendFile
file s appends
string s to file.
These computations may fail with:
HardwareFault
EIO
]
ResourceExhausted
ENOSPC
]
PermissionDenied
EFBIG
]
ResourceVanished
EPIPE
]
IllegalOperation