[project @ 1999-02-19 17:11:59 by simonm]
[ghc-hetmet.git] / ghc / tests / array / should_run / arr014.hs
1 {-# OPTIONS -fglasgow-exts #-}
2
3 -- !!! multi-dimensional arrays
4
5 module Main ( main ) where
6 import GlaExts
7 import Array
8
9 type TwoD s = MutableArray s Int (MutableArray s Int Int)
10
11 setup :: ST s (TwoD s)
12 setup = let isz = 10
13             imax = isz - 1        
14             osz = 2
15             omax = osz - 1 in
16         do
17             -- gives : undefined reference to `IOBase_error_closure'
18 --          x <- newArray (0, omax) (error "uninitialised")
19             dmy <- newArray (0, imax) 0      
20             x <- newArray (0, omax) dmy
21             as <- (sequence . replicate osz) (newArray (0, imax) 6)
22             mapM_ (\(i,v) -> writeArray x i v) (zip [0..omax] as)
23             return x      
24
25 main :: IO ()
26 main = do
27          a <- stToIO setup
28          return ()