[project @ 1997-03-14 07:52:06 by simonpj]
[ghc-hetmet.git] / ghc / lib / tests / Array / arr002 / Main.hs
1 -- Array creation, (index,value) list with duplicates.
2 -- 
3 -- Haskell library report 1.3 (and earlier) specifies
4 -- that `array' values created with lists containing dups,
5 -- are undefined ( _|_ ).
6 --
7 -- GHC-2.02 (and earlier) does not flag this as such, the
8 -- last (index,value) is instead used.
9 --
10 -- The report also specifies `array' is spine strict in
11 -- the (index,value) list argument and to check the
12 -- validity of the index values upon creation, it also
13 -- strict for the indices. To test this, we do (a!1)
14 -- twice, expecting to see the same value..
15 --
16 import Array
17
18 main =
19  let a1 = array (1,3) (zip (1:[1..3]) ['a'..'d']) in
20  print (a1!1) >>
21  print a1     >>
22  print (a1!1)
23