> My main comment is please don't ignore a simple update operation
> on immutable arrays, with a type something like
> update :: Ix ix => a ix e -> ix -> e -> a ix e
> I don't care about the name but I do care about the functionality.
> I'm perfectly happy with the naive, dirt simple, O(n) implementation
> that copies the whole array and makes the update in the copy. Yes,
> there is the // operation, but 95% of the time I just want to
> update a single element.
>
> Most functional languages leave this operation out, I presume because
> the feeling is that it is so expensive that no one would ever
> want to call it. But I've found myself wanting it lots of times,
> usually with very short arrays (say, length 4 or 8).
Sure, I can add it. Something like:
update :: (Ix ix, IArray a e) => a ix e -> ix -> e -> a ix e
update arr i v = arr // [(i,v)]
but I presume you'd prefer a more efficient implementation.
Actually, I'm slightly concerned about your use of small arrays: the static
(one-off) cost of allocating an array is quite high compared to eg. tuples
or records. Are arrays the only solution here?
Cheers,
Simon