Data.Array.ST.Safe
Copyright | (c) The University of Glasgow 2011 |
---|---|
License | BSD-style (see the file libraries/base/LICENSE) |
Maintainer | [email protected] |
Stability | experimental |
Portability | non-portable (uses Data.Array.MArray) |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Description
Mutable boxed and unboxed arrays in the ST
monad.
Safe API only of Data.Array.ST.
Since: 0.4.0.0
Boxed arrays
data STArray s i e :: * -> * -> * -> * Source
Mutable, boxed, non-strict arrays in the ST
monad. The type arguments are as follows:
-
s
: the state variable argument for theST
type -
i
: the index type of the array (should be an instance ofIx
) -
e
: the element type of the array.
runSTArray :: Ix i => (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
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 theST
type -
i
: the index type of the array (should be an instance ofIx
) -
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
MArray (STUArray s) Word64 (ST s) | |
MArray (STUArray s) Word32 (ST s) | |
MArray (STUArray s) Word16 (ST s) | |
MArray (STUArray s) Word8 (ST s) | |
MArray (STUArray s) Int64 (ST s) | |
MArray (STUArray s) Int32 (ST s) | |
MArray (STUArray s) Int16 (ST s) | |
MArray (STUArray s) Int8 (ST s) | |
MArray (STUArray s) Double (ST s) | |
MArray (STUArray s) Float (ST s) | |
MArray (STUArray s) Word (ST s) | |
MArray (STUArray s) Int (ST s) | |
MArray (STUArray s) Char (ST s) | |
MArray (STUArray s) Bool (ST s) | |
MArray (STUArray s) (StablePtr a) (ST s) | |
MArray (STUArray s) (FunPtr a) (ST s) | |
MArray (STUArray s) (Ptr a) (ST s) | |
Eq (STUArray s i e) |
runSTUArray :: Ix i => (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
module Data.Array.MArray.Safe
© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/7.10.3/docs/html/libraries/array-0.5.1.0/Data-Array-ST-Safe.html