| Copyright | (c) The University of Glasgow 1994-2008 |
|---|---|
| License | see libraries/base/LICENSE |
| Maintainer | libraries@haskell.org |
| Stability | internal |
| Portability | non-portable |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
GHC.IO.Device
Description
Type classes for I/O providers.
A low-level I/O provider where the data is bytes in memory.
Methods
read :: a ->PtrWord8 ->Int ->IOIntSource#
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 ->PtrWord8 ->Int ->IO (MaybeInt)Source#
Read up to the specified number of bytes, returning the number of bytes actually read, orNothing if the end of the stream has been reached.
write :: a ->PtrWord8 ->Int ->IO ()Source#
Write the specified number of bytes.
writeNonBlocking :: a ->PtrWord8 ->Int ->IOIntSource#
Write up to the specified number of bytes without blocking. Returns the actual number of bytes written.
I/O operations required for implementing aHandle.
Methods
ready :: a ->Bool ->Int ->IOBoolSource#
ready dev write msecs returnsTrue if the device has data to read (ifwrite isFalse) or space to write new data (ifwrite isTrue).msecs specifies how long to wait, in milliseconds.
closes the device. Further operations on the device should produce exceptions.
isTerminal :: a ->IOBoolSource#
returnsTrue if the device is a terminal or console.
isSeekable :: a ->IOBoolSource#
seek :: a ->SeekMode ->Integer ->IO ()Source#
seek to the specified position in the data.
return the current position in the data.
getSize :: a ->IOIntegerSource#
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.
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 ->IOIODeviceTypeSource#
returns theIODeviceType corresponding to this device.
duplicates the device, if possible. The new device is expected to share a file pointer with the original device (like Unixdup).
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 Unixdup2).
Type of a device that can be used to back aHandle (see alsomkFileHandle). The standard libraries provide creation ofHandles via Posix file operations with file descriptors (seemkHandleFromFD) with FD being the underlyingIODevice instance.
Users may provide custom instances ofIODevice which are expected to conform the following rules:
Constructors
| Directory | The standard libraries do not have direct support for this device type, but a user implementation is expected to provide a list of file names in the directory, in any order, separated by |
| Stream | A duplex communications channel (results in creation of a duplex |
| RegularFile | A file that may be read or written, and also may be seekable. |
| RawDevice | A "raw" (disk) device which supports block binary read and write operations and may be seekable only to positions of certain granularity (block- aligned). |
| EqIODeviceTypeSource# | Since: 4.2.0.0 |
Instance detailsDefined inGHC.IO.Device | |
A mode that determines the effect ofhSeekhdl mode i.
Constructors
| AbsoluteSeek | the position of |
| RelativeSeek | the position of |
| SeekFromEnd | the position of |
| EnumSeekModeSource# | Since: 4.2.0.0 |
Instance detailsDefined inGHC.IO.Device Methods succ ::SeekMode ->SeekModeSource# pred ::SeekMode ->SeekModeSource# toEnum ::Int ->SeekModeSource# fromEnum ::SeekMode ->IntSource# enumFrom ::SeekMode -> [SeekMode]Source# enumFromThen ::SeekMode ->SeekMode -> [SeekMode]Source# enumFromTo ::SeekMode ->SeekMode -> [SeekMode]Source# enumFromThenTo ::SeekMode ->SeekMode ->SeekMode -> [SeekMode]Source# | |
| EqSeekModeSource# | Since: 4.2.0.0 |
| OrdSeekModeSource# | Since: 4.2.0.0 |
| ReadSeekModeSource# | Since: 4.2.0.0 |
| ShowSeekModeSource# | Since: 4.2.0.0 |
| IxSeekModeSource# | Since: 4.2.0.0 |
Instance detailsDefined inGHC.IO.Device Methods range :: (SeekMode,SeekMode) -> [SeekMode]Source# index :: (SeekMode,SeekMode) ->SeekMode ->IntSource# unsafeIndex :: (SeekMode,SeekMode) ->SeekMode ->Int inRange :: (SeekMode,SeekMode) ->SeekMode ->BoolSource# rangeSize :: (SeekMode,SeekMode) ->IntSource# unsafeRangeSize :: (SeekMode,SeekMode) ->Int | |
Produced byHaddock version 2.20.0