|
System.IO | Portability | portable | Stability | provisional | Maintainer | libraries@haskell.org |
|
|
|
|
|
Description |
The standard IO library.
|
|
Synopsis |
|
|
|
Documentation |
|
data Handle |
|
|
data HandlePosn |
|
|
data IOMode |
Constructors | ReadMode | | WriteMode | | AppendMode | | ReadWriteMode | |
|
|
|
data BufferMode |
Constructors | NoBuffering | | LineBuffering | | BlockBuffering (Maybe Int) | |
|
|
|
data SeekMode |
Constructors | AbsoluteSeek | | RelativeSeek | | SeekFromEnd | |
|
|
|
stdin :: Handle |
|
stdout :: Handle |
|
stderr :: Handle |
|
openFile :: FilePath -> IOMode -> IO Handle |
|
hClose :: Handle -> IO () |
|
hFileSize :: Handle -> IO Integer |
|
hIsEOF :: Handle -> IO Bool |
|
isEOF :: IO Bool |
|
hSetBuffering :: Handle -> BufferMode -> IO () |
|
hGetBuffering :: Handle -> IO BufferMode |
|
hFlush :: Handle -> IO () |
|
hGetPosn :: Handle -> IO HandlePosn |
|
hSetPosn :: HandlePosn -> IO () |
|
hSeek :: Handle -> SeekMode -> Integer -> IO () |
|
hTell :: Handle -> IO Integer |
|
hWaitForInput :: Handle -> Int -> IO Bool |
|
hReady :: Handle -> IO Bool |
|
hGetChar :: Handle -> IO Char |
|
hGetLine :: Handle -> IO String |
|
hLookAhead :: Handle -> IO Char |
|
hGetContents :: Handle -> IO String |
|
hPutChar :: Handle -> Char -> IO () |
|
hPutStr :: Handle -> String -> IO () |
|
hPutStrLn :: Handle -> String -> IO () |
|
hPrint :: (Show a) => Handle -> a -> IO () |
|
hIsOpen :: Handle -> IO Bool |
|
hIsClosed :: Handle -> IO Bool |
|
hIsReadable :: Handle -> IO Bool |
|
hIsWritable :: Handle -> IO Bool |
|
hIsSeekable :: Handle -> IO Bool |
|
isAlreadyExistsError :: IOError -> Bool |
|
isDoesNotExistError :: IOError -> Bool |
|
isAlreadyInUseError :: IOError -> Bool |
|
isFullError :: IOError -> Bool |
|
isEOFError :: IOError -> Bool |
|
isIllegalOperation :: IOError -> Bool |
|
isPermissionError :: IOError -> Bool |
|
isUserError :: IOError -> Bool |
|
ioeGetErrorString :: IOError -> String |
|
ioeGetHandle :: IOError -> Maybe Handle |
|
ioeGetFileName :: IOError -> Maybe FilePath |
|
try :: IO a -> IO (Either Exception a) |
|
bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c |
|
bracket_ :: IO a -> (a -> IO b) -> IO c -> IO c |
|
data IO a |
A value of type IO a is a computation which, when performed,
does some I/O before returning a value of type a. There is really only one way to "perform" an I/O action: bind it to
Main.main in your program. When your program is run, the I/O will
be performed. It isn't possible to perform I/O from an arbitrary
function, unless that function is itself in the IO monad and called
at some point, directly or indirectly, from Main.main. IO is a monad, so IO actions can be combined using either the do-notation
or the >> and >>= operations from the Monad class.
| Instances | |
|
|
type FilePath = String |
|
type IOError = Exception |
|
ioError :: Exception -> IO a |
A variant of throw that can be used within the IO monad. Although ioError has a type that is an instance of the type of throw, the
two functions are subtly different: throw e `seq` return () ===> throw e
ioError e `seq` return () ===> return () The first example will cause the exception e to be raised,
whereas the second one won't. In fact, ioError will only cause
an exception to be raised when it is used within the IO monad.
The ioError variant should be used in preference to throw to
raise an exception within the IO monad because it guarantees
ordering with respect to other IO operations, whereas throw
does not. |
|
userError :: String -> IOError |
|
catch :: IO a -> (Exception -> IO a) -> IO a |
|
interact :: (String -> String) -> IO () |
|
putChar :: Char -> IO () |
|
putStr :: String -> IO () |
|
putStrLn :: String -> IO () |
|
print :: (Show a) => a -> IO () |
|
getChar :: IO Char |
|
getLine :: IO String |
|
getContents :: IO String |
|
readFile :: FilePath -> IO String |
|
writeFile :: FilePath -> String -> IO () |
|
appendFile :: FilePath -> String -> IO () |
|
readIO :: (Read a) => String -> IO a |
|
readLn :: (Read a) => IO a |
|
hPutBuf :: Handle -> Ptr a -> Int -> IO () |
|
hGetBuf :: Handle -> Ptr a -> Int -> IO Int |
|
fixIO :: (a -> IO a) -> IO a |
|
hSetEcho :: Handle -> Bool -> IO () |
|
hGetEcho :: Handle -> IO Bool |
|
hIsTerminalDevice :: Handle -> IO Bool |
|
Produced by Haddock version 0.4 |