Array optimisation...

Josef Svenningsson josefs at
Mon Feb 23 15:01:12 EST 2004

On Mon, 23 Feb 2004, MR K P SCHUPKE wrote:

> Was just thinking about GHC's implementation of arrays, and their
> poor performance. I know little about GHC's internal workings, but
> I was thinking about how array performance could be improved.
> What if when writing an array you instead construct a function:
> f :: (Ix x,Ix y) => Array a -> Ix x -> a -> Ix y -> a
> f a x b y | x==y = b
>           | otherwise = a!y
> Then the update in place operator // becomes a curried application
> of 'f' above.
> You could then define a a series of 'overlays' for a base array.
> The clever bit would be to get the garbage collector to merge
> the two as soon as any reference to the original array is
> discarded.
> Does GHC already do anything like this?
No it doesn't. But if you want this behaviour you should look at
Data.Array.Diff . I think that library does what you want.



More information about the Glasgow-haskell-users mailing list