array-0.5.4.0: Mutable and immutable arrays
Copyright(c) The University of Glasgow 2011
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityexperimental
Portabilitynon-portable (uses Data.Array.MArray)
Safe HaskellTrustworthy
LanguageHaskell2010

Data.Array.ST.Safe

Description

Mutable boxed and unboxed arrays in the ST monad.

Safe API only of Data.Array.ST.

Since: 0.4.0.0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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