
Am Dienstag 06 April 2010 21:51:47 schrieb Daniel Fischer:
An immutable array should be fine for this. When you modify one tree, you create a new array of 200 pointers to trees, 199 of them are just copied from the old array, one points to your new modified tree.
Of course, with STArrays, there would be no need to copy any pointers and allocate new arrays, so in principle it should be even more efficient, but boxed mutable arrays and the garbage collector don't play too well together (http://hackage.haskell.org/trac/ghc/ticket/650), so it might not be better.
Forgot to check before posting: it's fixed now, the fix will be in 6.12.2. And what Edward said, only pointers will be copied anyway, so a Map can well be better than an array, depends on your access patterns.