Library for IO operations like reading and writing files
that are not already contained in the prelude.
Author: Michael Hanus, Bernd Brassel
Version: June 2006
| Exported names: |
Datatypes:
Handle
| IOMode
| SeekMode
Constructors:
AbsoluteSeek
| AppendMode
| ReadMode
| RelativeSeek
| SeekFromEnd
| WriteMode
Functions:
getContents
| hClose
| hFlush
| hGetChar
| hGetContents
| hGetLine
| hIsEOF
| hIsReadable
| hIsWritable
| hPrint
| hPutChar
| hPutStr
| hPutStrLn
| hReady
| hSeek
| hWaitForInput
| hWaitForInputOrMsg
| hWaitForInputs
| hWaitForInputsOrMsg
| isEOF
| openFile
| stderr
| stdin
| stdout
| Summary of exported functions: |
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
| Imported modules: |
| Exported datatypes: |
The abstract type of a handle for a stream.
Constructors:
The modes for opening a file.
Constructors:
:: IOMode
:: IOMode
:: IOMode
The modes for positioning with hSeek in a file.
Constructors:
:: SeekMode
:: SeekMode
:: SeekMode
| Exported functions: |
:: Handle
Standard input stream.
:: Handle
Standard output stream.
:: Handle
Standard error stream.
:: String -> IOMode -> IO Handle
Opens a file in specified mode and returns a handle to it.
:: Handle -> IO ()
Closes a file handle and flushes the buffer in case of output file.
:: Handle -> IO ()
Flushes the buffer associated to handle in case of output file.
:: Handle -> IO Bool
Is handle at end of file?
:: IO Bool
Is standard input at end of file?
:: Handle -> SeekMode -> Int -> IO ()
Set the position of a handle to a seekable stream (e.g., a file).
If the second argument is AbsoluteSeek,
SeekFromEnd, or RelativeSeek,
the position is set relative to the beginning of the file,
to the end of the file, or to the current position, respectively.
:: Handle -> Int -> IO Bool
Waits until input is available on the given handle. If no input is available within t milliseconds, it returns False, otherwise it returns True.
Example call: (hWaitForInput handle timeout)
handle
- a handle for an input stream
timeout
- milliseconds to wait for input (< 0 : no time out)
:: [Handle] -> Int -> IO Int
Waits until input is available on some of the given handles. If no input is available within t milliseconds, it returns -1, otherwise it returns the index of the corresponding handle with the available data.
Example call: (hWaitForInputs handles timeout)
handles
- a list of handles for input streams
timeout
- milliseconds to wait for input (< 0 : no time out)
:: Handle -> [a] -> IO (Either Handle [a])
Waits until input is available on a given handles or a message
in the message stream. Usually, the message stream comes from an external port.
Thus, this operation implements a committed choice over receiving input
from an IO handle or an external port.
Note that the implementation of this operation works only with
Sicstus-Prolog 3.8.5 or higher (due to a bug in previous versions
of Sicstus-Prolog).
Example call: (hWaitForInputOrMsg handle msgs)
handle
- a handle for an input stream
msgs
- a stream of messages received via an external port (see Ports)
:: [Handle] -> [a] -> IO (Either Int [a])
Waits until input is available on some of the given handles or a message
in the message stream. Usually, the message stream comes from an external port.
Thus, this operation implements a committed choice over receiving input
from IO handles or an external port.
Note that the implementation of this operation works only with
Sicstus-Prolog 3.8.5 or higher (due to a bug in previous versions
of Sicstus-Prolog).
Example call: (hWaitForInputsOrMsg handles msgs)
handles
- a list of handles for input streams
msgs
- a stream of messages received via an external port (see Ports)
:: Handle -> IO Bool
Checks whether an input is available on a given handle.
:: Handle -> IO Char
Reads a character from an input handle and returns it.
:: Handle -> IO String
Reads a line from an input handle and returns it.
:: Handle -> IO String
Reads the complete contents from an input handle and closes the input handle before returning the contents.
:: IO String
Reads the complete contents from the standard input stream until EOF.
:: Handle -> Char -> IO ()
Puts a character to an output handle.
:: Handle -> String -> IO ()
Puts a string to an output handle.
:: Handle -> String -> IO ()
Puts a string with a newline to an output handle.
:: Handle -> a -> IO ()
Converts a term into a string and puts it to an output handle.
:: Handle -> IO Bool
Is the handle readable?
:: Handle -> IO Bool
Is the handle writable?