
25 Sep
2009
25 Sep
'09
2:56 a.m.
2009/9/25 Casey Hawthorne
How does one delare a 2D STUArray in Haskell?
Hi, STUArray, like other arrays is parametrized by the type of the index, the "i" in "STUArray s i e" [1]. 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). Cheers, Thu [1] http://hackage.haskell.org/packages/archive/array/0.2.0.0/doc/html/Data-Arra...