Haskell Core Libraries (base package)ParentContentsIndex
GHC.Handle
Portability non-portable
Stability internal
Maintainer libraries@haskell.org
Description
This module defines the basic operations on I/O "handles".
Synopsis
withHandle :: String -> Handle -> (Handle__ -> IO (Handle__, a)) -> IO a
withHandle' :: String -> Handle -> MVar Handle__ -> (Handle__ -> IO (Handle__, a)) -> IO a
withHandle_ :: String -> Handle -> (Handle__ -> IO a) -> IO a
wantWritableHandle :: String -> Handle -> (Handle__ -> IO a) -> IO a
wantReadableHandle :: String -> Handle -> (Handle__ -> IO a) -> IO a
wantSeekableHandle :: String -> Handle -> (Handle__ -> IO a) -> IO a
newEmptyBuffer :: RawBuffer -> BufferState -> Int -> Buffer
allocateBuffer :: Int -> BufferState -> IO Buffer
readCharFromBuffer :: RawBuffer -> Int -> IO (Char, Int)
writeCharIntoBuffer :: RawBuffer -> Int -> Char -> IO Int
flushWriteBufferOnly :: Handle__ -> IO ()
flushWriteBuffer :: FD -> Bool -> Buffer -> IO Buffer
flushReadBuffer :: FD -> Buffer -> IO Buffer
fillReadBuffer :: FD -> Bool -> Bool -> Buffer -> IO Buffer
readRawBuffer :: String -> FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
readRawBufferPtr :: String -> FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
writeRawBuffer :: String -> FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
writeRawBufferPtr :: String -> FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
unlockFile :: CInt -> IO CInt
write_off :: CInt -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
write_rawBuffer :: CInt -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
read_off :: FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
read_rawBuffer :: FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
ioe_closedHandle :: IO a
ioe_EOF :: IO a
ioe_notReadable :: IO a
ioe_notWritable :: IO a
stdin :: Handle
stdout :: Handle
stderr :: Handle
data IOMode
= ReadMode
| WriteMode
| AppendMode
| ReadWriteMode
data IOModeEx
= BinaryMode IOMode
| TextMode IOMode
openFile :: FilePath -> IOMode -> IO Handle
openFileEx :: FilePath -> IOModeEx -> IO Handle
openFd :: FD -> Maybe FDType -> FilePath -> IOMode -> Bool -> Bool -> IO Handle
fdToHandle :: FD -> IO Handle
hFileSize :: Handle -> IO Integer
hIsEOF :: Handle -> IO Bool
isEOF :: IO Bool
hLookAhead :: Handle -> IO Char
hSetBuffering :: Handle -> BufferMode -> IO ()
hSetBinaryMode :: Handle -> Bool -> IO ()
hFlush :: Handle -> IO ()
hDuplicate :: Handle -> IO Handle
hDuplicateTo :: Handle -> Handle -> IO ()
hClose :: Handle -> IO ()
hClose_help :: Handle__ -> IO Handle__
data HandlePosn = HandlePosn Handle HandlePosition
hGetPosn :: Handle -> IO HandlePosn
hSetPosn :: HandlePosn -> IO ()
data SeekMode
= AbsoluteSeek
| RelativeSeek
| SeekFromEnd
hSeek :: Handle -> SeekMode -> Integer -> IO ()
hTell :: Handle -> IO Integer
hIsOpen :: Handle -> IO Bool
hIsClosed :: Handle -> IO Bool
hIsReadable :: Handle -> IO Bool
hIsWritable :: Handle -> IO Bool
hGetBuffering :: Handle -> IO BufferMode
hIsSeekable :: Handle -> IO Bool
hSetEcho :: Handle -> Bool -> IO ()
hGetEcho :: Handle -> IO Bool
hIsTerminalDevice :: Handle -> IO Bool
Documentation
withHandle :: String -> Handle -> (Handle__ -> IO (Handle__, a)) -> IO a
withHandle' :: String -> Handle -> MVar Handle__ -> (Handle__ -> IO (Handle__, a)) -> IO a
withHandle_ :: String -> Handle -> (Handle__ -> IO a) -> IO a
wantWritableHandle :: String -> Handle -> (Handle__ -> IO a) -> IO a
wantReadableHandle :: String -> Handle -> (Handle__ -> IO a) -> IO a
wantSeekableHandle :: String -> Handle -> (Handle__ -> IO a) -> IO a
newEmptyBuffer :: RawBuffer -> BufferState -> Int -> Buffer
allocateBuffer :: Int -> BufferState -> IO Buffer
readCharFromBuffer :: RawBuffer -> Int -> IO (Char, Int)
writeCharIntoBuffer :: RawBuffer -> Int -> Char -> IO Int
flushWriteBufferOnly :: Handle__ -> IO ()
flushWriteBuffer :: FD -> Bool -> Buffer -> IO Buffer
flushReadBuffer :: FD -> Buffer -> IO Buffer
fillReadBuffer :: FD -> Bool -> Bool -> Buffer -> IO Buffer
readRawBuffer :: String -> FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
readRawBufferPtr :: String -> FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
writeRawBuffer :: String -> FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
writeRawBufferPtr :: String -> FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
unlockFile :: CInt -> IO CInt
write_off :: CInt -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
write_rawBuffer :: CInt -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
read_off :: FD -> Bool -> Ptr CChar -> Int -> CInt -> IO CInt
read_rawBuffer :: FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
ioe_closedHandle :: IO a
ioe_EOF :: IO a
ioe_notReadable :: IO a
ioe_notWritable :: IO a
stdin :: Handle
stdout :: Handle
stderr :: Handle
data IOMode
Constructors
ReadMode
WriteMode
AppendMode
ReadWriteMode
Instances
Eq IOMode
Ord IOMode
Ix IOMode
Enum IOMode
Read IOMode
Show IOMode
data IOModeEx
Constructors
BinaryMode IOMode
TextMode IOMode
Instances
Eq IOModeEx
Read IOModeEx
Show IOModeEx
openFile :: FilePath -> IOMode -> IO Handle
openFileEx :: FilePath -> IOModeEx -> IO Handle
openFd :: FD -> Maybe FDType -> FilePath -> IOMode -> Bool -> Bool -> IO Handle
fdToHandle :: FD -> IO Handle
hFileSize :: Handle -> IO Integer
hIsEOF :: Handle -> IO Bool
isEOF :: IO Bool
hLookAhead :: Handle -> IO Char
hSetBuffering :: Handle -> BufferMode -> IO ()
hSetBinaryMode :: Handle -> Bool -> IO ()
On Windows, reading a file in text mode (which is the default) will translate CRLF to LF, and writing will translate LF to CRLF. This is usually what you want with text files. With binary files this is undesirable; also, as usual under Microsoft operating systems, text mode treats control-Z as EOF. Setting binary mode using hSetBinaryMode turns off all special treatment of end-of-line and end-of-file characters.
hFlush :: Handle -> IO ()
hDuplicate :: Handle -> IO Handle
Returns a duplicate of the original handle, with its own buffer and file pointer. The original handle's buffer is flushed, including discarding any input data, before the handle is duplicated.
hDuplicateTo :: Handle -> Handle -> IO ()

Makes the second handle a duplicate of the first handle. The second handle will be closed first, if it is not already.

This can be used to retarget the standard Handles, for example:

 do h <- openFile "mystdout" WriteMode
    hDuplicateTo h stdout
hClose :: Handle -> IO ()
hClose_help :: Handle__ -> IO Handle__
data HandlePosn
Constructors
HandlePosn Handle HandlePosition
Instances
Eq HandlePosn
Show HandlePosn
hGetPosn :: Handle -> IO HandlePosn
hSetPosn :: HandlePosn -> IO ()
data SeekMode
Constructors
AbsoluteSeek
RelativeSeek
SeekFromEnd
Instances
Eq SeekMode
Ord SeekMode
Ix SeekMode
Enum SeekMode
Read SeekMode
Show SeekMode
hSeek :: Handle -> SeekMode -> Integer -> IO ()
hTell :: Handle -> IO Integer
hIsOpen :: Handle -> IO Bool
hIsClosed :: Handle -> IO Bool
hIsReadable :: Handle -> IO Bool
hIsWritable :: Handle -> IO Bool
hGetBuffering :: Handle -> IO BufferMode
hIsSeekable :: Handle -> IO Bool
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