| Copyright | (c) The University of Glasgow 2001 |
|---|---|
| License | BSD-style (see the file libraries/base/LICENSE) |
| Maintainer | [email protected] |
| Stability | experimental |
| Portability | non-portable (uses Data.Array.Base) |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
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.
class Monad m => MArray (a :: Type -> Type -> Type) e (m :: Type -> Type) 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.
getBounds, getNumElements, (newArray | unsafeNewArray_), unsafeRead, unsafeWrite
module Data.Ix
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. The first and second element of the tuple specifies the lowest and highest index, respectively.
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. The first and second element of the tuple specifies the lowest and highest index, respectively.
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. The first and second element of the tuple specifies the lowest and highest index, respectively.
newGenArray :: (MArray a e m, Ix i) => (i, i) -> (i -> m e) -> m (a i e) Source
Constructs a mutable array using a generator function. It invokes the generator function in ascending order of the indices.
Since: array-0.5.6.0
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
modifyArray :: (MArray a e m, Ix i) => a i e -> i -> (e -> e) -> m () Source
Modify an element in a mutable array
Since: array-0.5.6.0
modifyArray' :: (MArray a e m, Ix i) => a i e -> i -> (e -> e) -> m () Source
Modify an element in a mutable array. Strict in the written element.
Since: array-0.5.6.0
foldlMArray' :: (MArray a e m, Ix i) => (b -> e -> b) -> b -> a i e -> m b Source
Strict accumulating left-associative fold.
Since: array-0.5.8.0
foldrMArray' :: (MArray a e m, Ix i) => (e -> b -> b) -> b -> a i e -> m b Source
Strict accumulating right-associative fold.
Since: array-0.5.8.0
mapMArrayM_ :: (MArray a e m, Ix i) => (e -> m b) -> a i e -> m () Source
Map elements to monadic actions, sequence them left-to-right, and discard the results.
Since: array-0.5.8.0
forMArrayM_ :: (MArray a e m, Ix i) => a i e -> (e -> m b) -> m () Source
forMArrayM_ is mapMArrayM_ with its arguments flipped.
Since: array-0.5.8.0
foldlMArrayM' :: (MArray a e m, Ix i) => (b -> e -> m b) -> b -> a i e -> m b Source
Strict accumulating left-associative monadic fold.
Since: array-0.5.8.0
foldrMArrayM' :: (MArray a e m, Ix i) => (e -> b -> m b) -> b -> a i e -> m b Source
Strict accumulating right-associative monadic fold.
Since: array-0.5.8.0
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.
getBounds :: (MArray a e m, Ix i) => a i e -> m (i, i) Source
Returns the bounds of the array (lowest,highest).
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.
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.
© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/9.12.1/docs/libraries/array-0.5.8.0-8d84/Data-Array-MArray.html