array-0.5.1.1: Mutable and immutable arrays

Copyright (c) The University of Glasgow 2001 BSD-style (see the file libraries/base/LICENSE) libraries@haskell.org experimental non-portable (uses Data.Array.MArray) None Haskell2010

Data.Array.IO

Description

Mutable boxed and unboxed arrays in the IO monad.

Synopsis

# IO arrays with boxed elements

data IOArray i e :: * -> * -> * Source #

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

 # MethodsgetBounds :: Ix i => IOArray i e -> IO (i, i) #getNumElements :: Ix i => IOArray i e -> IO IntnewArray :: Ix i => (i, i) -> e -> IO (IOArray i e) #newArray_ :: Ix i => (i, i) -> IO (IOArray i e) #unsafeNewArray_ :: Ix i => (i, i) -> IO (IOArray i e)unsafeRead :: Ix i => IOArray i e -> Int -> IO eunsafeWrite :: Ix i => IOArray i e -> Int -> e -> IO () Eq (IOArray i e) Methods(==) :: IOArray i e -> IOArray i e -> Bool #(/=) :: IOArray i e -> IOArray i e -> Bool #

# 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

# Doing I/O with IOUArrays

Arguments

 :: Handle Handle to read from -> IOUArray Int Word8 Array in which to place the values -> Int Number of Word8s to read -> IO Int Returns: the number of Word8s actually read, which might be smaller than the number requested if the end of file was reached.

Reads a number of Word8s from the specified Handle directly into an array.

Arguments

 :: Handle Handle to write to -> IOUArray Int Word8 Array to write from -> Int Number of Word8s to write -> IO ()

Writes an array of Word8 to the specified Handle.