array-0.5.8.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 HaskellTrustworthy
LanguageHaskell2010

Data.Array.ST

Description

Mutable boxed and unboxed arrays in the ST monad.

Synopsis

Boxed arrays

data STArray s i e #

Mutable, boxed, non-strict arrays in the ST monad. The type arguments are as follows:

  • s: the state variable argument for the ST type
  • i: the index type of the array (should be an instance of Ix)
  • e: the element type of the array.

Instances

Instances details
MArray (STArray s) e (ST s) Source # 
Instance details

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

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

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

Eq (STArray s i e)

Since: base-2.1

Instance details

Defined in GHC.Arr

Methods

(==) :: STArray s i e -> STArray s i e -> Bool #

(/=) :: STArray s i e -> STArray s i e -> Bool #

runSTArray :: (forall s. ST s (STArray s i e)) -> Array i e Source #

A safe way to create and work with a mutable array before returning an immutable array for later perusal. This function avoids copying the array before returning it - it uses unsafeFreeze internally, but this wrapper is a safe interface to that function.

Unboxed arrays

data STUArray s i e Source #

A mutable array with unboxed elements, that can be manipulated in the ST monad. The type arguments are as follows:

  • s: the state variable argument for the ST type
  • 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.

An STUArray will generally be more efficient (in terms of both time and space) than the equivalent boxed version (STArray) with the same element type. However, STUArray is strict in its elements - so don't use STUArray if you require the non-strictness that STArray provides.

Instances

Instances details
MArray (STUArray s) Int16 (ST s) Source # 
Instance details

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

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

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

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

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

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

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

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

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

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

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

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

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

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

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

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

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

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

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

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

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

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

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

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

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

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

Defined in Data.Array.Base

Methods

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

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

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) Source #

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

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

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

Defined in Data.Array.Base

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

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)) Source #

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

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

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

Defined in Data.Array.Base

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

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)) Source #

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

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

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

Defined in Data.Array.Base

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

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)) Source #

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

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

Eq (STUArray s i e) Source # 
Instance details

Defined in Data.Array.Base

Methods

(==) :: STUArray s i e -> STUArray s i e -> Bool #

(/=) :: STUArray s i e -> STUArray s i e -> Bool #

runSTUArray :: (forall s. ST s (STUArray s i e)) -> UArray i e Source #

A safe way to create and work with an unboxed mutable array before returning an immutable array for later perusal. This function avoids copying the array before returning it - it uses unsafeFreeze internally, but this wrapper is a safe interface to that function.

Overloaded mutable array interface