Array optimisation...

MR K P SCHUPKE k.schupke at imperial.ac.uk
Mon Feb 23 13:53:00 EST 2004


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?

	Regards,
	Keean Schupke.


More information about the Glasgow-haskell-users mailing list