Stream: ideas

Topic: Persistent data structures


view this post on Zulip Qqwy / Marten (Jun 20 2022 at 10:10):

I read the module documentation of List yesterday evening, which I found very enlightening, especially the section on backing List by a plain 'capacity doubling' array rather than any other persistent data structure.

Now I am wondering however, how ergonomic could we make it to use a particular persistent datastructure?

For instance, Clojure uses HAMT vectors as main collection datastructure, to great success. (Hash-Array-Mapped-Trie-based vectors, c.f. https://hypirion.com/musings/understanding-persistent-vector-pt-1 )
Even more recent are RRB vectors (Relaxed-Radix-Balanced vectors, c.f. https://github.com/nicolasstucki/scala-rrb-vector).

view this post on Zulip Qqwy / Marten (Jun 20 2022 at 10:14):

The ideas of these are to make sure that all of appending, prepending, updating, insertion, splitting, concatenation and (parallel) iteration very fast (as fast as, up to a constant factor, as the best of both worlds of linked lists/arrays), while being an immutable data structure (and doing in-place mutation if there is only one reference).

view this post on Zulip Qqwy / Marten (Jun 20 2022 at 10:15):

Those kinds of structures can probably be built fully in just Roc, but if it is not ergonomic to use them, then it is unlikely for them to be used much over plain Lists.

view this post on Zulip Qqwy / Marten (Jun 20 2022 at 10:31):

I'm not sure what the best approach would be. I am aware of clear evidence that in languages where this is not done, people end up using whatever is available in the standard library for nearly anything and everything.

view this post on Zulip Qqwy / Marten (Jun 20 2022 at 10:32):

In part probably because of a bandwagoning effect, where libraries only support lists as input/output because other libraries only support lists as well.

view this post on Zulip Qqwy / Marten (Jun 20 2022 at 10:34):

This can for instance be seen in e.g. Haskell, Elixir, and Elm.

view this post on Zulip Folkert de Vries (Jun 20 2022 at 11:25):

only real downside is not having literals


Last updated: Jun 16 2026 at 16:19 UTC