I am working on an program that uses a large list of IORef
's to a data type. Which is the more memory/processor-efficient way to do this:
[IORef Foo]
or
IORef [Foo]
Ignore the fact that I am using lists instead of vectors or arrays.
I am working on an program that uses a large list of IORef
's to a data type. Which is the more memory/processor-efficient way to do this:
[IORef Foo]
or
IORef [Foo]
Ignore the fact that I am using lists instead of vectors or arrays.
With
[IORef Foo]
you can update elements easily, withIORef [Foo]
, you can only update the whole list. Since you're likely wanting to efficiently update elements without copying, you want[IORef Foo]
. Think, you want a list of mutable things, not a mutable list of immutable things.As an example