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 IOError a)
data IO a
type FilePath = String
type IOError = IOException
ioError :: IOError -> IO a
userError :: String -> IOError
catch :: IO a -> (IOError -> 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
Instances
Eq IOMode
Ord IOMode
Ix IOMode
Enum IOMode
Read IOMode
Show IOMode
data BufferMode
Constructors
NoBuffering
LineBuffering
BlockBuffering (Maybe Int)
Instances
Eq BufferMode
Ord BufferMode
Read BufferMode
Show BufferMode
data SeekMode
Constructors
AbsoluteSeek
RelativeSeek
SeekFromEnd
Instances
Eq SeekMode
Ord SeekMode
Ix SeekMode
Enum SeekMode
Read SeekMode
Show SeekMode
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 IOError a)
The construct try comp exposes IO errors which occur within a computation, and which are not fully handled. Other exceptions are not caught by this variant; to catch all exceptions, use try from Control.Exception.
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 = IOException
The Haskell 98 type for exceptions in the IO monad. In Haskell 98, this is an opaque type.
ioError :: IOError -> IO a
userError :: String -> IOError
catch :: IO a -> (IOError -> 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 ()
Set the echoing status of a handle connected to a terminal (GHC only).
hGetEcho :: Handle -> IO Bool
Get the echoing status of a handle connected to a terminal (GHC only).
hIsTerminalDevice :: Handle -> IO Bool
Is the handle connected to a terminal? (GHC only)
Produced by Haddock version 0.4