rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.42k stars 12.73k forks source link

Add Persistent Collections to libcollections #16521

Closed Gankra closed 9 years ago

Gankra commented 10 years ago

Many people want (fully) persistent collections in Rust to make it more pure-functional friendly. Rust doesn't have GC, Laziness, or Memoization (and I don't think it should), so we can't do any of the really fancy stuff described in the oft-cited "purely functional data structures". Instead, we should go practical and simple by copying several of the structures described in Scala's Concrete Immutable Collections.

Of particular interest is:

Ideally, we could do something magic by genercizing over Box and Rc to reuse a lot of code between our persistent and ephemeral tree-based collections, but I'm doubtful it will be that easy.

Gankra commented 10 years ago

cc @aturon, would appreciate any thoughts you have on the matter

ghost commented 10 years ago

I have a port of Clojure's persistent vector in https://github.com/jakub-/rust-persistent-vector but it's mostly a translation rather than an idiomatic Rust implementation so it needs extra work.

aturon commented 10 years ago

This is definitely an area we want to explore. Just a couple of notes:

I'd love to see a repo started for collecting (no pun intended) some of these data structures!

reem commented 10 years ago

I actually began this project a week or so ago, and do have plans on continuing it. What's there so far is mostly a port of Haskell's Data.Map and a singly-linked list, but I have much more planned:

https://github.com/reem/adamantium

Laziness and Arc are really all that is needed to do cool things here. Few data structures will have complex cycles.

steveklabnik commented 9 years ago

I'm pulling a massive triage effort to get us ready for 1.0. As part of this, I'm moving stuff that's wishlist-like to the RFCs repo, as that's where major new things should get discussed/prioritized.

This issue has been moved to the RFCs repo: rust-lang/rfcs#825