array-0.5.1.1: 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.Base)
Safe HaskellNone
LanguageHaskell2010

Data.Array.MArray

Contents

Description

An overloaded interface to mutable arrays. For array types which can be used with this interface, see Data.Array.IO, Data.Array.ST, and Data.Array.Storable.

Synopsis

Class of mutable array types

class Monad m => MArray a e m where Source #

Class of mutable array types.

An array type has the form (a i e) where a is the array type constructor (kind * -> * -> *), i is the index type (a member of the class Ix), and e is the element type.

The MArray class is parameterised over both a and e (so that instances specialised to certain element types can be defined, in the same way as for IArray), and also over the type of the monad, m, in which the mutable array will be manipulated.

Minimal complete definition

getBounds, getNumElements, unsafeRead, unsafeWrite

Methods

getBounds :: Ix i => a i e -> m (i, i) Source #

Returns the bounds of the array

newArray :: Ix i => (i, i) -> e -> m (a i e) Source #

Builds a new array, with every element initialised to the supplied value.

newArray_ :: Ix i => (i, i) -> m (a i e) Source #

Builds a new array, with every element initialised to an undefined value. In a monadic context in which operations must be deterministic (e.g. the ST monad), the array elements are initialised to a fixed but undefined value, such as zero.

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 ()

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 ()

Storable e => MArray StorableArray e IO Source # 

Methods

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

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

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

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

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

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

unsafeWrite :: Ix i => StorableArray i e -> Int -> e -> 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 ()

MArray (STArray s) e (ST s) Source # 

Methods

getBounds :: Ix i => STArray s i e -> ST s (i, i) Source #

getNumElements :: Ix i => STArray s i e -> ST s Int

newArray :: Ix i => (i, i) -> e -> ST s (STArray s i e) Source #

newArray_ :: Ix i => (i, i) -> ST s (STArray s i e) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STArray s i e)

unsafeRead :: Ix i => STArray s i e -> Int -> ST s e

unsafeWrite :: Ix i => STArray s i e -> Int -> e -> ST s ()

MArray (STArray s) e (ST s) Source # 

Methods

getBounds :: Ix i => STArray s i e -> ST s (i, i) Source #

getNumElements :: Ix i => STArray s i e -> ST s Int

newArray :: Ix i => (i, i) -> e -> ST s (STArray s i e) Source #

newArray_ :: Ix i => (i, i) -> ST s (STArray s i e) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STArray s i e)

unsafeRead :: Ix i => STArray s i e -> Int -> ST s e

unsafeWrite :: Ix i => STArray s i e -> Int -> e -> ST s ()

MArray (STUArray s) Word64 (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i Word64 -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i Word64 -> ST s Int

newArray :: Ix i => (i, i) -> Word64 -> ST s (STUArray s i Word64) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word64) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word64)

unsafeRead :: Ix i => STUArray s i Word64 -> Int -> ST s Word64

unsafeWrite :: Ix i => STUArray s i Word64 -> Int -> Word64 -> ST s ()

MArray (STUArray s) Word32 (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i Word32 -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i Word32 -> ST s Int

newArray :: Ix i => (i, i) -> Word32 -> ST s (STUArray s i Word32) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word32) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word32)

unsafeRead :: Ix i => STUArray s i Word32 -> Int -> ST s Word32

unsafeWrite :: Ix i => STUArray s i Word32 -> Int -> Word32 -> ST s ()

MArray (STUArray s) Word16 (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i Word16 -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i Word16 -> ST s Int

newArray :: Ix i => (i, i) -> Word16 -> ST s (STUArray s i Word16) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word16) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word16)

unsafeRead :: Ix i => STUArray s i Word16 -> Int -> ST s Word16

unsafeWrite :: Ix i => STUArray s i Word16 -> Int -> Word16 -> ST s ()

MArray (STUArray s) Word8 (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i Word8 -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i Word8 -> ST s Int

newArray :: Ix i => (i, i) -> Word8 -> ST s (STUArray s i Word8) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word8) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word8)

unsafeRead :: Ix i => STUArray s i Word8 -> Int -> ST s Word8

unsafeWrite :: Ix i => STUArray s i Word8 -> Int -> Word8 -> ST s ()

MArray (STUArray s) Int64 (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i Int64 -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i Int64 -> ST s Int

newArray :: Ix i => (i, i) -> Int64 -> ST s (STUArray s i Int64) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int64) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int64)

unsafeRead :: Ix i => STUArray s i Int64 -> Int -> ST s Int64

unsafeWrite :: Ix i => STUArray s i Int64 -> Int -> Int64 -> ST s ()

MArray (STUArray s) Int32 (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i Int32 -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i Int32 -> ST s Int

newArray :: Ix i => (i, i) -> Int32 -> ST s (STUArray s i Int32) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int32) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int32)

unsafeRead :: Ix i => STUArray s i Int32 -> Int -> ST s Int32

unsafeWrite :: Ix i => STUArray s i Int32 -> Int -> Int32 -> ST s ()

MArray (STUArray s) Int16 (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i Int16 -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i Int16 -> ST s Int

newArray :: Ix i => (i, i) -> Int16 -> ST s (STUArray s i Int16) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int16) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int16)

unsafeRead :: Ix i => STUArray s i Int16 -> Int -> ST s Int16

unsafeWrite :: Ix i => STUArray s i Int16 -> Int -> Int16 -> ST s ()

MArray (STUArray s) Int8 (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i Int8 -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i Int8 -> ST s Int

newArray :: Ix i => (i, i) -> Int8 -> ST s (STUArray s i Int8) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int8) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int8)

unsafeRead :: Ix i => STUArray s i Int8 -> Int -> ST s Int8

unsafeWrite :: Ix i => STUArray s i Int8 -> Int -> Int8 -> ST s ()

MArray (STUArray s) Double (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i Double -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i Double -> ST s Int

newArray :: Ix i => (i, i) -> Double -> ST s (STUArray s i Double) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Double) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Double)

unsafeRead :: Ix i => STUArray s i Double -> Int -> ST s Double

unsafeWrite :: Ix i => STUArray s i Double -> Int -> Double -> ST s ()

MArray (STUArray s) Float (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i Float -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i Float -> ST s Int

newArray :: Ix i => (i, i) -> Float -> ST s (STUArray s i Float) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Float) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Float)

unsafeRead :: Ix i => STUArray s i Float -> Int -> ST s Float

unsafeWrite :: Ix i => STUArray s i Float -> Int -> Float -> ST s ()

MArray (STUArray s) Word (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i Word -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i Word -> ST s Int

newArray :: Ix i => (i, i) -> Word -> ST s (STUArray s i Word) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Word)

unsafeRead :: Ix i => STUArray s i Word -> Int -> ST s Word

unsafeWrite :: Ix i => STUArray s i Word -> Int -> Word -> ST s ()

MArray (STUArray s) Int (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i Int -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i Int -> ST s Int

newArray :: Ix i => (i, i) -> Int -> ST s (STUArray s i Int) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Int)

unsafeRead :: Ix i => STUArray s i Int -> Int -> ST s Int

unsafeWrite :: Ix i => STUArray s i Int -> Int -> Int -> ST s ()

MArray (STUArray s) Char (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i Char -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i Char -> ST s Int

newArray :: Ix i => (i, i) -> Char -> ST s (STUArray s i Char) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Char) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Char)

unsafeRead :: Ix i => STUArray s i Char -> Int -> ST s Char

unsafeWrite :: Ix i => STUArray s i Char -> Int -> Char -> ST s ()

MArray (STUArray s) Bool (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i Bool -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i Bool -> ST s Int

newArray :: Ix i => (i, i) -> Bool -> ST s (STUArray s i Bool) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i Bool) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i Bool)

unsafeRead :: Ix i => STUArray s i Bool -> Int -> ST s Bool

unsafeWrite :: Ix i => STUArray s i Bool -> Int -> Bool -> ST s ()

MArray (STUArray s) (StablePtr a) (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i (StablePtr a) -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i (StablePtr a) -> ST s Int

newArray :: Ix i => (i, i) -> StablePtr a -> ST s (STUArray s i (StablePtr a)) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i (StablePtr a)) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i (StablePtr a))

unsafeRead :: Ix i => STUArray s i (StablePtr a) -> Int -> ST s (StablePtr a)

unsafeWrite :: Ix i => STUArray s i (StablePtr a) -> Int -> StablePtr a -> ST s ()

MArray (STUArray s) (FunPtr a) (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i (FunPtr a) -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i (FunPtr a) -> ST s Int

newArray :: Ix i => (i, i) -> FunPtr a -> ST s (STUArray s i (FunPtr a)) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i (FunPtr a)) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i (FunPtr a))

unsafeRead :: Ix i => STUArray s i (FunPtr a) -> Int -> ST s (FunPtr a)

unsafeWrite :: Ix i => STUArray s i (FunPtr a) -> Int -> FunPtr a -> ST s ()

MArray (STUArray s) (Ptr a) (ST s) Source # 

Methods

getBounds :: Ix i => STUArray s i (Ptr a) -> ST s (i, i) Source #

getNumElements :: Ix i => STUArray s i (Ptr a) -> ST s Int

newArray :: Ix i => (i, i) -> Ptr a -> ST s (STUArray s i (Ptr a)) Source #

newArray_ :: Ix i => (i, i) -> ST s (STUArray s i (Ptr a)) Source #

unsafeNewArray_ :: Ix i => (i, i) -> ST s (STUArray s i (Ptr a))

unsafeRead :: Ix i => STUArray s i (Ptr a) -> Int -> ST s (Ptr a)

unsafeWrite :: Ix i => STUArray s i (Ptr a) -> Int -> Ptr a -> ST s ()

The Ix class and operations

module Data.Ix

Constructing mutable arrays

newArray :: (MArray a e m, Ix i) => (i, i) -> e -> m (a i e) Source #

Builds a new array, with every element initialised to the supplied value.

newArray_ :: (MArray a e m, Ix i) => (i, i) -> m (a i e) Source #

Builds a new array, with every element initialised to an undefined value. In a monadic context in which operations must be deterministic (e.g. the ST monad), the array elements are initialised to a fixed but undefined value, such as zero.

newListArray :: (MArray a e m, Ix i) => (i, i) -> [e] -> m (a i e) Source #

Constructs a mutable array from a list of initial elements. The list gives the elements of the array in ascending order beginning with the lowest index.

Reading and writing mutable arrays

readArray :: (MArray a e m, Ix i) => a i e -> i -> m e Source #

Read an element from a mutable array

writeArray :: (MArray a e m, Ix i) => a i e -> i -> e -> m () Source #

Write an element in a mutable array

Derived arrays

mapArray :: (MArray a e' m, MArray a e m, Ix i) => (e' -> e) -> a i e' -> m (a i e) Source #

Constructs a new array derived from the original array by applying a function to each of the elements.

mapIndices :: (MArray a e m, Ix i, Ix j) => (i, i) -> (i -> j) -> a j e -> m (a i e) Source #

Constructs a new array derived from the original array by applying a function to each of the indices.

Deconstructing mutable arrays

getBounds :: (MArray a e m, Ix i) => a i e -> m (i, i) Source #

Returns the bounds of the array

getElems :: (MArray a e m, Ix i) => a i e -> m [e] Source #

Return a list of all the elements of a mutable array

getAssocs :: (MArray a e m, Ix i) => a i e -> m [(i, e)] Source #

Return a list of all the associations of a mutable array, in index order.

Conversions between mutable and immutable arrays

freeze :: (Ix i, MArray a e m, IArray b e) => a i e -> m (b i e) Source #

Converts a mutable array (any instance of MArray) to an immutable array (any instance of IArray) by taking a complete copy of it.

thaw :: (Ix i, IArray a e, MArray b e m) => a i e -> m (b i e) Source #

Converts an immutable array (any instance of IArray) into a mutable array (any instance of MArray) by taking a complete copy of it.