[project @ 2002-09-20 13:15:07 by ross]
[packages/old-time.git] / Data / Array / MArray.hs
1 -----------------------------------------------------------------------------
2 -- |
3 -- Module : Data.Array.MArray
4 -- Copyright : (c) The University of Glasgow 2001
5 -- License : BSD-style (see the file libraries/base/LICENSE)
6 --
7 -- Maintainer : libraries@haskell.org
8 -- Stability : experimental
9 -- Portability : non-portable
10 --
11 -- An overloaded interface to mutable arrays. For array types which can be
12 -- used with this interface, see "Data.Array.IO", "Data.Array.ST",
13 -- and "Data.Array.Storable".
14 --
15 -----------------------------------------------------------------------------
16
17 module Data.Array.MArray (
18 -- * Class of mutable array types
19 MArray, -- :: (* -> * -> *) -> * -> (* -> *) -> class
20
21 -- * Class of array types with bounds
22 HasBounds, -- :: (* -> * -> *) -> class
23
24 -- * The @Ix@ class and operations
25 module Data.Ix,
26
27 -- * Constructing mutable arrays
28 newArray, -- :: (MArray a e m, Ix i) => (i,i) -> e -> m (a i e)
29 newArray_, -- :: (MArray a e m, Ix i) => (i,i) -> m (a i e)
30 newListArray, -- :: (MArray a e m, Ix i) => (i,i) -> [e] -> m (a i e)
31
32 -- * Reading and writing mutable arrays
33 readArray, -- :: (MArray a e m, Ix i) => a i e -> i -> m e
34 writeArray, -- :: (MArray a e m, Ix i) => a i e -> i -> e -> m ()
35
36 -- * Derived arrays
37 mapArray, -- :: (MArray a e' m, MArray a e m, Ix i) => (e' -> e) -> a i e' -> m (a i e)
38 mapIndices, -- :: (MArray a e m, Ix i, Ix j) => (i,i) -> (i -> j) -> a j e -> m (a i e)
39
40 -- * Deconstructing mutable arrays
41 bounds, -- :: (HasBounds a, Ix i) => a i e -> (i,i)
42 indices, -- :: (HasBounds a, Ix i) => a i e -> [i]
43 getElems, -- :: (MArray a e m, Ix i) => a i e -> m [e]
44 getAssocs, -- :: (MArray a e m, Ix i) => a i e -> m [(i, e)]
45
46 -- * Conversions between mutable and immutable arrays
47 freeze, -- :: (Ix i, MArray a e m, IArray b e) => a i e -> m (b i e)
48 unsafeFreeze, -- :: (Ix i, MArray a e m, IArray b e) => a i e -> m (b i e)
49 thaw, -- :: (Ix i, IArray a e, MArray b e m) => a i e -> m (b i e)
50 unsafeThaw, -- :: (Ix i, IArray a e, MArray b e m) => a i e -> m (b i e)
51 ) where
52
53 import Prelude
54
55 import Data.Ix
56 import Data.Array.Base