HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulerebase-1.21.2Haskell2010

Rebase.GHC.IO.Device

  • 2 types
  • 2 classes
  • Packagerebase-1.21.2
  • Exports4
  • LanguageHaskell2010
  • LicenceMIT
  • SourceDevice.hs
classclass IODevice a where
#

I/O operations required for implementing a System.IO.Handle.

Methods

  • ready :: a -> Bool -> Int -> IO Bool

    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 ()

    closes the device. Further operations on the device should produce exceptions.

  • isTerminal :: a -> IO Bool

    returns True if the device is a terminal or console.

  • isSeekable :: a -> IO Bool

    returns True if the device supports seek operations.

  • seek :: a -> SeekMode -> Integer -> IO Integer

    seek to the specified position in the data.

  • tell :: a -> IO Integer

    return the current position in the data.

  • getSize :: a -> IO Integer

    return the size of the data.

  • setSize :: a -> Integer -> IO ()

    change the size of the data.

  • setEcho :: a -> Bool -> IO ()

    for terminal devices, changes whether characters are echoed on the device.

  • getEcho :: a -> IO Bool

    returns the current echoing status.

  • setRaw :: a -> Bool -> IO ()

    some devices (e.g. terminals) support a "raw" mode where characters entered are immediately made available to the program. If available, this operation enables raw mode.

  • devType :: a -> IO IODeviceType

    returns the IODeviceType corresponding to this device.

  • dup :: a -> IO a

    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 a

    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).

Instances1IODevice
  • IODevice FDDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.FD
datadata IODeviceType
#

Type of a device that can be used to back a Handle (see also mkFileHandle). The standard libraries provide creation of Handles via Posix file operations with file descriptors (see mkHandleFromFD) with FD being the underlying IODevice instance.

Users may provide custom instances of IODevice 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 '\0' characters, excluding the "." and ".." names. See also getDirectoryContents. Seek operations are not supported on directories (other than to the zero position).

  • Stream

    A duplex communications channel (results in creation of a duplex Handle). The standard libraries use this device type when creating Handles for open sockets.

  • 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).

Instances1Eq
  • Eq IODeviceTypeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
classclass RawIO a where
#

A low-level I/O provider where the data is bytes in memory. The Word64 offsets currently have no effect on POSIX system or consoles where the implicit behaviour of the C runtime is assumed to move the file pointer on every read/write without needing an explicit seek.

Methods

  • read :: a -> Ptr Word8 -> Word64 -> Int -> IO Int

    Read up to the specified number of bytes starting from a specified offset, 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 -> Word64 -> Int -> IO (Maybe Int)

    Read up to the specified number of bytes starting from a specified offset, returning the number of bytes actually read, or Nothing if the end of the stream has been reached.

  • write :: a -> Ptr Word8 -> Word64 -> Int -> IO ()

    Write the specified number of bytes starting at a given offset.

  • writeNonBlocking :: a -> Ptr Word8 -> Word64 -> Int -> IO Int

    Write up to the specified number of bytes without blocking starting at a given offset. Returns the actual number of bytes written.

Instances1RawIO
  • RawIO FDDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.FD
datadata SeekMode
#

A mode that determines the effect of GHC.Internal.System.IO.hSeek hdl mode i.

Constructors

  • AbsoluteSeek

    the position of hdl is set to i.

  • RelativeSeek

    the position of hdl is set to offset i from the current position.

  • SeekFromEnd

    the position of hdl is set to offset i from the end of the file.

Instances6Enum, Eq, Ord, Read, Show, Ix
  • Enum SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Eq SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Ord SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Read SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Show SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device
  • Ix SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Device