foundation icon indicating copy to clipboard operation
foundation copied to clipboard

Treeish Array

Open AnthonyJacob opened this issue 8 years ago • 5 comments

Habe you thought about providing immutable update O(1) Array by default like clojure and elm does?

AnthonyJacob avatar Mar 15 '17 11:03 AnthonyJacob

How do you provide immutable o(1) array ?

vincenthz avatar Mar 17 '17 20:03 vincenthz

It is obviously a lie but it has some truth in it.

AnthonyJacob avatar Mar 18 '17 06:03 AnthonyJacob

So this is basically a tree, the foundation array need to stay a traditional arrays with o(1) operations, and support thaw-o(1)update(s)-freeze and will not change structure. However in the future have different array variants would be useful; we already looked into this with the Array of UArray (already available in the repository), which goes in the same direction as what you're talking about here but instead on a hardcoded 2 levels.

vincenthz avatar Mar 18 '17 08:03 vincenthz

The reason I post here this proposal is if I were Haskell beginner and I would be in the situation where list O(N) access and update are no longer fast enough for me I would naturally look into Collection library for something with array or vector in its name with easy mutating and array like characteristics.

As a lazy programmer, I also don't want to thaw and freeze every time unless I have to. For almost all my work true mutable array is overkill, because I don't need that performance.

AnthonyJacob avatar Mar 18 '17 10:03 AnthonyJacob

I don't disagree. this is the plan I'm taking about adding some "Array" variants. It's unlikely to happen straight away, although I have some tree implementations for map/set that are upcoming and could be use as a base for this, but unless someone is willing to look into this, it will probably take some time

vincenthz avatar Mar 18 '17 18:03 vincenthz