[Haskell-cafe] How does one delare a 2D STUArray in Haskell?
noteed at gmail.com
Fri Sep 25 02:56:25 EDT 2009
2009/9/25 Casey Hawthorne <caseyh at istar.ca>:
> How does one delare a 2D STUArray in Haskell?
STUArray, like other arrays is parametrized by the type of the index,
the "i" in "STUArray s i e" . That "i" is should be an instance of
Ix which is a class of the types that can be used as indices. If you
want to use 2D indices, that's fine as pairs (of types that are
themselves in Ix) are instances of Ix.
In your code, (Int,Int) (2d) and Word32 (1d) are the indice types. So
STUArray s (Word32,Word32) Bool
would be the 2d version of an array indiced by Word32 (that is, an
array indiced by pairs of Word32).
More information about the Haskell-Cafe