|
|
|
|
| Contents |
- Buffers
- Files
- MappedFiles
- Pipes
- Arrays as streams
- Sockets
- Streams
|
|
| Description |
| The naming is all subject to change, we're interested in
functionality first. |
|
| Synopsis |
|
|
|
|
| Buffers |
|
| data Buffer |
| A mutable array of bytes that can be passed to foreign functions. | | Instances | |
|
|
| withBuffer :: Buffer -> (Ptr Word8 -> IO a) -> IO a |
|
| data ImmutableBuffer |
| An immutable array of bytes | | Instances | |
|
|
The idea is that Buffer should be useful for text encoding/decoding. Implementation notes: on GHC, Buffer could be implemented by IOUArray,
using a pinned ByteArray# as the underlying object, so that the buffer
address can be passed to foreign functions. (a StorableArray would do for Buffer, but an IOUArray will be more
efficient). |
|
| Files |
|
| data File |
|
|
| data FileInputStream |
|
|
| data FileOutputStream |
|
|
| type FileOffset = Integer |
|
| openFile :: FilePath -> IOMode -> IO File |
|
| closeFile :: File -> IO () |
|
| fileSize :: File -> IO Integer |
|
| fileSetSize :: File -> Integer -> IO () |
|
| fileRead :: File -> FileOffset -> Integer -> Buffer -> IO () |
|
| fileGet :: File -> FileOffset -> Integer -> IO ImmutableBuffer |
|
| fileWrite :: File -> FileOffset -> Integer -> Buffer -> IO () |
|
| fileInputStream :: File -> FileOffset -> IO FileInputStream |
|
| fileOutputStream :: File -> FileOffset -> IO FileOutputStream |
|
| mapFile :: File -> FileOffset -> Integer -> MapMode -> IO MappedFile |
|
| MappedFiles |
|
| data MappedFile |
| A portion of a File mapped directly into memory. The data can
be read and written using the array operations, and streams to the
data can be created using marrayInputStream and marrayOutputStream. | | Instances | |
|
|
| A MappedFile might be implemented as a StorableArray, with a
ForeignPtr inside it. The finalizer can unmap the file. |
|
| Pipes |
|
| data PipeInputStream |
|
|
| data PipeOutputStream |
|
|
| createPipe :: IO (PipeInputStream, PipeOutputStream) |
|
| Arrays as streams |
|
| data ArrayInputStream |
| An input stream created from an array. | | Instances | |
|
|
| data ArrayOutputStream |
| An output stream created from an array. | | Instances | |
|
|
| iarrayInputStream :: (Ix i, IArray a Word8) => a i Word8 -> i -> ArrayInputStream |
| Creates an ArrayInputStream from an immutable array |
|
| marrayInputStream :: (Ix i, MArray a Word8 IO) => a i Word8 -> i -> ArrayInputStream |
| Creates an ArrayInputStream from a mutable array |
|
| marrayOutputStream :: (Ix i, MArray a Word8 IO) => a i Word8 -> i -> ArrayOutputStream |
| Creates an ArrayOutputStream from a mutable array |
|
| Sockets |
|
| The socket support won't live in System.IO, it will be in
Network.Socket as before. |
|
| data Socket |
|
|
| data SocketInputStream |
|
|
| data SocketOutputStream |
|
|
| socketGetInputStream :: Socket -> SocketInputStream |
|
| socketGetOutputStream :: Socket -> SocketOutputStream |
|
Input and output streams for a socket can be closed
independently. Each socket has only one pair of input/output
streams, hence these functions are pure. |
|
| Streams |
|
| class Stream s where |
| | Methods | | closeStream :: s -> IO () | | | isEOS :: s -> IO Bool | | Note: objections have been raised about this method, and
are still to be resolved. It doesn't make as much sense
for output streams as it does for input streams. | | | setBufferMode :: s -> BufferMode -> IO Bool | | Sets the buffering mode on the stream. Returns True if
the buffereing mode was set, or False if it wasn't. If the
stream does not support buffereing, it may return False here. | | | getBufferMode :: s -> IO BufferMode | | Returns the current buffering mode for a stream. On a
stream that does not support buffering, the result will always
be NoBuffering. | | | flush :: s -> IO () | | Flushes the buffer to the operating system for an output
buffer, or discards buffered data for an input buffer. | | | sync :: s -> IO Bool | | Flushes the buffered data as far as possible, even to the
physical media if it can. It returns True if the data
has definitely been flushed as far as it can go: to the
disk for a disk file, to the screen for a terminal, and so on. |
| | | Instances | |
|
|
| class InputStream s where |
| | Methods | | streamGet :: s -> IO Word8 | | | streamReadBuffer :: s -> Integer -> Buffer -> IO () | | | streamGetBuffer :: s -> Integer -> IO ImmutableBuffer | | | streamGetContents :: s -> IO [Word8] | | | streamGetAvailable :: s -> IO [Word8] | | Gets any data which can be read without blocking. |
| | | Instances | |
|
|
| class OutputStream s where |
| | Methods | | streamPut :: s -> Word8 -> IO () | | | streamPuts :: s -> [Word8] -> IO () | | | streamWriteBuffer :: s -> Integer -> Buffer -> IO () | | | streamPutBuffer :: s -> Integer -> ImmutableBuffer -> IO () |
| | | Instances | |
|
|
| Produced by Haddock version 0.4 |