Haskell Core Libraries (base package)ParentContentsIndex
System.IO
Portability portable
Stability provisional
Maintainer libraries@haskell.org
Description
The standard IO library.
Synopsis
data Handle
data HandlePosn = HandlePosn Handle HandlePosition
data IOMode
= ReadMode
| WriteMode
| AppendMode
| ReadWriteMode
data BufferMode
= NoBuffering
| LineBuffering
| BlockBuffering (Maybe Int)
data SeekMode
= 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
type FilePath = String
type IOError = Exception
ioError :: Exception -> IO a
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
Documentation
data Handle
Instances
Typeable Handle
Eq Handle
Show Handle
data HandlePosn
Constructors
HandlePosn Handle HandlePosition
Instances
Eq HandlePosn
Show 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
MonadPlus IO
MonadError IOError IO
MonadFix IO
MonadIO IO
MArray IOArray e IO
MArray IOUArray Bool IO
MArray IOUArray Char IO
MArray IOUArray Int IO
MArray IOUArray Word IO
MArray IOUArray (Ptr a) IO
MArray IOUArray (FunPtr a) IO
MArray IOUArray Float IO
MArray IOUArray Double IO
MArray IOUArray (StablePtr a) IO
MArray IOUArray Int8 IO
MArray IOUArray Int16 IO
MArray IOUArray Int32 IO
MArray IOUArray Int64 IO
MArray IOUArray Word8 IO
MArray IOUArray Word16 IO
MArray IOUArray Word32 IO
MArray IOUArray Word64 IO
(Storable e) => MArray StorableArray e IO
(Typeable a) => Typeable (IO a)
Functor IO
Monad IO
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