array-0.5.2.0: Mutable and immutable arrays

Copyright(c) The University of Glasgow 2001
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityexperimental
Portabilitynon-portable (uses Data.Array.MArray)
Safe HaskellNone
LanguageHaskell2010

Data.Array.IO

Contents

Description

Mutable boxed and unboxed arrays in the IO monad.

Synopsis

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

MArray IOArray e IO Source # 

Methods

getBounds :: Ix i => IOArray i e -> IO (i, i) Source #

getNumElements :: Ix i => IOArray i e -> IO Int

newArray :: Ix i => (i, i) -> e -> IO (IOArray i e) Source #

newArray_ :: Ix i => (i, i) -> IO (IOArray i e) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOArray i e)

unsafeRead :: Ix i => IOArray i e -> Int -> IO e

unsafeWrite :: 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 Source #

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

MArray IOUArray Bool IO Source # 

Methods

getBounds :: Ix i => IOUArray i Bool -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i Bool -> IO Int

newArray :: Ix i => (i, i) -> Bool -> IO (IOUArray i Bool) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Bool) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Bool)

unsafeRead :: Ix i => IOUArray i Bool -> Int -> IO Bool

unsafeWrite :: Ix i => IOUArray i Bool -> Int -> Bool -> IO ()

MArray IOUArray Char IO Source # 

Methods

getBounds :: Ix i => IOUArray i Char -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i Char -> IO Int

newArray :: Ix i => (i, i) -> Char -> IO (IOUArray i Char) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Char) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Char)

unsafeRead :: Ix i => IOUArray i Char -> Int -> IO Char

unsafeWrite :: Ix i => IOUArray i Char -> Int -> Char -> IO ()

MArray IOUArray Double IO Source # 

Methods

getBounds :: Ix i => IOUArray i Double -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i Double -> IO Int

newArray :: Ix i => (i, i) -> Double -> IO (IOUArray i Double) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Double) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Double)

unsafeRead :: Ix i => IOUArray i Double -> Int -> IO Double

unsafeWrite :: Ix i => IOUArray i Double -> Int -> Double -> IO ()

MArray IOUArray Float IO Source # 

Methods

getBounds :: Ix i => IOUArray i Float -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i Float -> IO Int

newArray :: Ix i => (i, i) -> Float -> IO (IOUArray i Float) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Float) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Float)

unsafeRead :: Ix i => IOUArray i Float -> Int -> IO Float

unsafeWrite :: Ix i => IOUArray i Float -> Int -> Float -> IO ()

MArray IOUArray Int IO Source # 

Methods

getBounds :: Ix i => IOUArray i Int -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i Int -> IO Int

newArray :: Ix i => (i, i) -> Int -> IO (IOUArray i Int) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Int) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Int)

unsafeRead :: Ix i => IOUArray i Int -> Int -> IO Int

unsafeWrite :: Ix i => IOUArray i Int -> Int -> Int -> IO ()

MArray IOUArray Int8 IO Source # 

Methods

getBounds :: Ix i => IOUArray i Int8 -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i Int8 -> IO Int

newArray :: Ix i => (i, i) -> Int8 -> IO (IOUArray i Int8) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Int8) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Int8)

unsafeRead :: Ix i => IOUArray i Int8 -> Int -> IO Int8

unsafeWrite :: Ix i => IOUArray i Int8 -> Int -> Int8 -> IO ()

MArray IOUArray Int16 IO Source # 

Methods

getBounds :: Ix i => IOUArray i Int16 -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i Int16 -> IO Int

newArray :: Ix i => (i, i) -> Int16 -> IO (IOUArray i Int16) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Int16) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Int16)

unsafeRead :: Ix i => IOUArray i Int16 -> Int -> IO Int16

unsafeWrite :: Ix i => IOUArray i Int16 -> Int -> Int16 -> IO ()

MArray IOUArray Int32 IO Source # 

Methods

getBounds :: Ix i => IOUArray i Int32 -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i Int32 -> IO Int

newArray :: Ix i => (i, i) -> Int32 -> IO (IOUArray i Int32) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Int32) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Int32)

unsafeRead :: Ix i => IOUArray i Int32 -> Int -> IO Int32

unsafeWrite :: Ix i => IOUArray i Int32 -> Int -> Int32 -> IO ()

MArray IOUArray Int64 IO Source # 

Methods

getBounds :: Ix i => IOUArray i Int64 -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i Int64 -> IO Int

newArray :: Ix i => (i, i) -> Int64 -> IO (IOUArray i Int64) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Int64) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Int64)

unsafeRead :: Ix i => IOUArray i Int64 -> Int -> IO Int64

unsafeWrite :: Ix i => IOUArray i Int64 -> Int -> Int64 -> IO ()

MArray IOUArray Word IO Source # 

Methods

getBounds :: Ix i => IOUArray i Word -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i Word -> IO Int

newArray :: Ix i => (i, i) -> Word -> IO (IOUArray i Word) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Word) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Word)

unsafeRead :: Ix i => IOUArray i Word -> Int -> IO Word

unsafeWrite :: Ix i => IOUArray i Word -> Int -> Word -> IO ()

MArray IOUArray Word8 IO Source # 

Methods

getBounds :: Ix i => IOUArray i Word8 -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i Word8 -> IO Int

newArray :: Ix i => (i, i) -> Word8 -> IO (IOUArray i Word8) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Word8) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Word8)

unsafeRead :: Ix i => IOUArray i Word8 -> Int -> IO Word8

unsafeWrite :: Ix i => IOUArray i Word8 -> Int -> Word8 -> IO ()

MArray IOUArray Word16 IO Source # 

Methods

getBounds :: Ix i => IOUArray i Word16 -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i Word16 -> IO Int

newArray :: Ix i => (i, i) -> Word16 -> IO (IOUArray i Word16) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Word16) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Word16)

unsafeRead :: Ix i => IOUArray i Word16 -> Int -> IO Word16

unsafeWrite :: Ix i => IOUArray i Word16 -> Int -> Word16 -> IO ()

MArray IOUArray Word32 IO Source # 

Methods

getBounds :: Ix i => IOUArray i Word32 -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i Word32 -> IO Int

newArray :: Ix i => (i, i) -> Word32 -> IO (IOUArray i Word32) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Word32) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Word32)

unsafeRead :: Ix i => IOUArray i Word32 -> Int -> IO Word32

unsafeWrite :: Ix i => IOUArray i Word32 -> Int -> Word32 -> IO ()

MArray IOUArray Word64 IO Source # 

Methods

getBounds :: Ix i => IOUArray i Word64 -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i Word64 -> IO Int

newArray :: Ix i => (i, i) -> Word64 -> IO (IOUArray i Word64) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i Word64) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i Word64)

unsafeRead :: Ix i => IOUArray i Word64 -> Int -> IO Word64

unsafeWrite :: Ix i => IOUArray i Word64 -> Int -> Word64 -> IO ()

MArray IOUArray (StablePtr a) IO Source # 

Methods

getBounds :: Ix i => IOUArray i (StablePtr a) -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i (StablePtr a) -> IO Int

newArray :: Ix i => (i, i) -> StablePtr a -> IO (IOUArray i (StablePtr a)) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i (StablePtr a)) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i (StablePtr a))

unsafeRead :: Ix i => IOUArray i (StablePtr a) -> Int -> IO (StablePtr a)

unsafeWrite :: Ix i => IOUArray i (StablePtr a) -> Int -> StablePtr a -> IO ()

MArray IOUArray (Ptr a) IO Source # 

Methods

getBounds :: Ix i => IOUArray i (Ptr a) -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i (Ptr a) -> IO Int

newArray :: Ix i => (i, i) -> Ptr a -> IO (IOUArray i (Ptr a)) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i (Ptr a)) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i (Ptr a))

unsafeRead :: Ix i => IOUArray i (Ptr a) -> Int -> IO (Ptr a)

unsafeWrite :: Ix i => IOUArray i (Ptr a) -> Int -> Ptr a -> IO ()

MArray IOUArray (FunPtr a) IO Source # 

Methods

getBounds :: Ix i => IOUArray i (FunPtr a) -> IO (i, i) Source #

getNumElements :: Ix i => IOUArray i (FunPtr a) -> IO Int

newArray :: Ix i => (i, i) -> FunPtr a -> IO (IOUArray i (FunPtr a)) Source #

newArray_ :: Ix i => (i, i) -> IO (IOUArray i (FunPtr a)) Source #

unsafeNewArray_ :: Ix i => (i, i) -> IO (IOUArray i (FunPtr a))

unsafeRead :: Ix i => IOUArray i (FunPtr a) -> Int -> IO (FunPtr a)

unsafeWrite :: Ix i => IOUArray i (FunPtr a) -> Int -> FunPtr a -> IO ()

Eq (IOUArray i e) Source # 

Methods

(==) :: IOUArray i e -> IOUArray i e -> Bool #

(/=) :: IOUArray i e -> IOUArray i e -> Bool #

Overloaded mutable array interface

Doing I/O with IOUArrays

hGetArray Source #

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.

hPutArray Source #

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.