base-4.2.0.0: Basic librariesSource codeContentsIndex
GHC.IO.Device
Portabilitynon-portable
Stabilityinternal
Maintainerlibraries@haskell.org
Description
Type classes for I/O providers.
Synopsis
class RawIO a where
read :: a -> Ptr Word8 -> Int -> IO Int
readNonBlocking :: a -> Ptr Word8 -> Int -> IO (Maybe Int)
write :: a -> Ptr Word8 -> Int -> IO ()
writeNonBlocking :: a -> Ptr Word8 -> Int -> IO Int
class IODevice a where
ready :: a -> Bool -> Int -> IO Bool
close :: a -> IO ()
isTerminal :: a -> IO Bool
isSeekable :: a -> IO Bool
seek :: a -> SeekMode -> Integer -> IO ()
tell :: a -> IO Integer
getSize :: a -> IO Integer
setSize :: a -> Integer -> IO ()
setEcho :: a -> Bool -> IO ()
getEcho :: a -> IO Bool
setRaw :: a -> Bool -> IO ()
devType :: a -> IO IODeviceType
dup :: a -> IO a
dup2 :: a -> a -> IO a
data IODeviceType
= Directory
| Stream
| RegularFile
| RawDevice
data SeekMode
= AbsoluteSeek
| RelativeSeek
| SeekFromEnd
Documentation
class RawIO a whereSource
A low-level I/O provider where the data is bytes in memory.
Methods
read :: a -> Ptr Word8 -> Int -> IO IntSource
Read up to the specified number of bytes, returning the number of bytes actually read. This function should only block if there is no data available. If there is not enough data available, then the function should just return the available data. A return value of zero indicates that the end of the data stream (e.g. end of file) has been reached.
readNonBlocking :: a -> Ptr Word8 -> Int -> IO (Maybe Int)Source
Read up to the specified number of bytes, returning the number of bytes actually read, or Nothing if the end of the stream has been reached.
write :: a -> Ptr Word8 -> Int -> IO ()Source
Write the specified number of bytes.
writeNonBlocking :: a -> Ptr Word8 -> Int -> IO IntSource
Write up to the specified number of bytes without blocking. Returns the actual number of bytes written.
show/hide Instances
class IODevice a whereSource
I/O operations required for implementing a Handle.
Methods
ready :: a -> Bool -> Int -> IO BoolSource
ready dev write msecs returns True if the device has data to read (if write is False) or space to write new data (if write is True). msecs specifies how long to wait, in milliseconds.
close :: a -> IO ()Source
closes the device. Further operations on the device should produce exceptions.
isTerminal :: a -> IO BoolSource
returns True if the device is a terminal or console.
isSeekable :: a -> IO BoolSource
returns True if the device supports seek operations.
seek :: a -> SeekMode -> Integer -> IO ()Source
seek to the specified position in the data.
tell :: a -> IO IntegerSource
return the current position in the data.
getSize :: a -> IO IntegerSource
return the size of the data.
setSize :: a -> Integer -> IO ()Source
change the size of the data.
setEcho :: a -> Bool -> IO ()Source
for terminal devices, changes whether characters are echoed on the device.
getEcho :: a -> IO BoolSource
returns the current echoing status.
setRaw :: a -> Bool -> IO ()Source
some devices (e.g. terminals) support a raw mode where characters entered are immediately made available to the program. If available, this operations enables raw mode.
devType :: a -> IO IODeviceTypeSource
returns the IODeviceType corresponding to this device.
dup :: a -> IO aSource
duplicates the device, if possible. The new device is expected to share a file pointer with the original device (like Unix dup).
dup2 :: a -> a -> IO aSource
dup2 source target replaces the target device with the source device. The target device is closed first, if necessary, and then it is made into a duplicate of the first device (like Unix dup2).
show/hide Instances
data IODeviceType Source
Constructors
Directory
Stream
RegularFile
RawDevice
show/hide Instances
data SeekMode Source
A mode that determines the effect of hSeek hdl mode i, as follows:
Constructors
AbsoluteSeekthe position of hdl is set to i.
RelativeSeekthe position of hdl is set to offset i from the current position.
SeekFromEndthe position of hdl is set to offset i from the end of the file.
show/hide Instances
Produced by Haddock version 2.6.0