2 -- This one fails in Hugs (Feb 2001)
8 -- All in main is only to show the strange behaviour.
10 -- arrS is the array that foo (NB (1.0,1)) shows in Hugs.
11 -- But (foo (NB (1.0,1)))==arrS is False.
13 -- If I write NB (f,p) -> hCMt [(p,listArray ((1,1),(1,1)) [f])] instead of line 16
14 -- the bug disappears. That is also the reason why I have to keep the data declaration RD.
15 -- If I put the type signature of line 18 in scope the bug also disappears.
16 -- If I write hCMt po_arL = (accumArray (\a _-> a) ZM ((1,1),(1,2)) []) //
17 -- (map (\(po,ar) -> ((1,po),M ar)) po_arL)
18 -- instead of line 19 and 20 it also vanishes.
20 data CM a = ZM | M (Array (Int,Int) a) deriving (Show,Eq)
22 data RD = NB !(Double,Int)
25 let arr = foo (NB (1.0,1))
26 -- arr = { (1,1) -> M { (1,1) -> 1.0 }, (1,2) -> ZM }
28 -- All these should return True
29 putStr ("arr==arrS "++show (arr==arrS)++"\n")
30 putStr ("arrS==arr "++show (arrS==arr)++"\n")
31 putStr ("bnds arr arrS "++show ((bounds arr)==(bounds arrS))++"\n")
32 putStr ("bnds +id arr arrS "++show (((bounds.id) arr)==((bounds) arrS))++"\n")
33 putStr ("id +bnds arr arrS "++show (((id.bounds) arr)==((bounds) arrS))++"\n")
36 foo :: RD -> Array (Int,Int) (CM Double)
38 NB (f,p) -> h where h = hCMt [(p,listArray ((1,1),(1,1)) [f])]
39 -- h = { (1,p) -> M { (1,1) -> f }, other -> ZM }
41 --h0CMt :: Array (Int, Int) (CM Double)
42 -- h0CMt = { (1,1) -> ZM, (1,2) -> ZM }
43 h0CMt = accumArray (\a _-> a) ZM ((1,1),(1,2)) []
45 hCMt prs = h0CMt // (map (\(po,ar) -> ((1,po),M ar)) prs)
46 -- [ (1,p), M { (1,1) -> f } ]
49 arrS :: Array (Int,Int) (CM Double)
50 arrS = listArray ((1,1),(1,2)) [M (listArray ((1,1),(1,1)) [1.0]),ZM]