> I agree, but I also agree with Lennart that both sorts of arrays are needed.
Yes, I agree on that; language design is, as always, a compromise
between the desirable semantics (in this case, as lazy as possible),
and desirable efficency, and we don't know yet how to make lazy arrays
a la LML arrays as (potentially) efficient as current Haskell accumArray.
So here is a concrete suggestion:
1) Keep accumarray as it is (but like foldr-like behaviour instead of
foldl).
2) Add one more function to the prelude (or a standard module,
to be imported explicitly):
filterArray f z b list =
array b [ i := foldr f z [ x | j <- indices b, i==j ]
| i <- indices b
]
The only difference between assocArray and filterArray would be
that filterArray is lazy and ignores indices out of bound.
----
Another possibility would be to have only one, the lazy one,
and to use strictness annotations when the extra efficiency is desired;
but there seems to be a consensus against strictness annotations
(re the "newtype" discussion thread.)
But maybe the distaste is only for annotated *constructors* ?
-- Thomas