| Haskell Hierarchical Libraries (base package) | Source code | Contents | Index

Data.Array.IO

Portability | non-portable (uses Data.Array.MArray)
Stability | experimental
Maintainer | libraries@haskell.org

Contents

`IO` arrays with boxed elements
`IO` arrays with unboxed elements
Overloaded mutable array interface
Doing I/O with `IOUArray`s

Description
Mutable boxed and unboxed arrays in the IO monad.
Synopsis

data IOArray i e
data IOUArray i e
castIOUArray :: IOUArray ix a -> IO (IOUArray ix b)
module Data.Array.MArray
hGetArray :: Handle -> IOUArray Int Word8 -> Int -> IO Int
hPutArray :: Handle -> IOUArray Int Word8 -> Int -> IO ()

`IO` arrays with boxed elements
data IOArray i e

An `IOArray` is a mutable, boxed, non-strict array in the `IO` monad. The type arguments are as follows:

- `i`: the index type of the array (should be an instance of `Ix`)
- `e`: the element type of the array.

Instances

Typeable2 IOArray
MArray IOArray e IO
IArray (IOToDiffArray IOArray) e
Eq (IOArray i e)

`IO` arrays with unboxed elements
data IOUArray i e

Mutable, unboxed, strict arrays in the `IO` monad. The type arguments are as follows:

- `i`: the index type of the array (should be an instance of `Ix`)
- `e`: the element type of the array. Only certain element types are supported: see Data.Array.MArray for a list of instances.

Instances

Typeable2 IOUArray
MArray IOUArray Bool IO
MArray IOUArray Char IO
MArray IOUArray Double IO
MArray IOUArray Float IO
MArray IOUArray Int IO
MArray IOUArray Int16 IO
MArray IOUArray Int32 IO
MArray IOUArray Int64 IO
MArray IOUArray Int8 IO
MArray IOUArray Word IO
MArray IOUArray Word16 IO
MArray IOUArray Word32 IO
MArray IOUArray Word64 IO
MArray IOUArray Word8 IO
MArray IOUArray (FunPtr a) IO
MArray IOUArray (Ptr a) IO
MArray IOUArray (StablePtr a) IO
IArray (IOToDiffArray IOUArray) Char
IArray (IOToDiffArray IOUArray) Double
IArray (IOToDiffArray IOUArray) Float
IArray (IOToDiffArray IOUArray) Int
IArray (IOToDiffArray IOUArray) Int16
IArray (IOToDiffArray IOUArray) Int32
IArray (IOToDiffArray IOUArray) Int64
IArray (IOToDiffArray IOUArray) Int8
IArray (IOToDiffArray IOUArray) Word
IArray (IOToDiffArray IOUArray) Word16
IArray (IOToDiffArray IOUArray) Word32
IArray (IOToDiffArray IOUArray) Word64
IArray (IOToDiffArray IOUArray) Word8
IArray (IOToDiffArray IOUArray) (FunPtr a)
IArray (IOToDiffArray IOUArray) (Ptr a)
IArray (IOToDiffArray IOUArray) (StablePtr a)

castIOUArray :: IOUArray ix a -> IO (IOUArray ix b)
Casts an `IOUArray` with one element type into one with a different element type. All the elements of the resulting array are undefined (unless you know what you're doing...).
Overloaded mutable array interface
module Data.Array.MArray
Doing I/O with `IOUArray`s
hGetArray

:: Handle | Handle to read from
-> IOUArray Int Word8 | Array in which to place the values
-> Int | Number of `Word8`s to read
-> IO Int | Returns: the number of `Word8`s actually read, which might be smaller than the number requested if the end of file was reached.
Reads a number of `Word8`s from the specified `Handle` directly into an array.

hPutArray

:: Handle | Handle to write to
-> IOUArray Int Word8 | Array to write from
-> Int | Number of `Word8`s to write
-> IO () |
Writes an array of `Word8` to the specified `Handle`.

Produced by Haddock version 0.8