Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Collection library wish list #812

Open
Tracked by #3921
rossberg opened this issue Oct 31, 2019 · 3 comments
Open
Tracked by #3921

Collection library wish list #812

rossberg opened this issue Oct 31, 2019 · 3 comments
Assignees
Labels
feature New feature or request P2 medium priority, resolve within a couple of milestones

Comments

@rossberg
Copy link
Contributor

The current Trie and Set provide fairly low-level interfaces whose use is not safe, e.g., because the user might accidentally mix multiple hash or eq functions. For a more complete picture, we should provide the following:

  • functional unordered maps and sets (e.g. hash table)
  • functional ordered maps and sets (e.g. red-black tree)
  • imperative versions of the above (as wrappers where adequate)
  • imperative dictionaries (i.e., maps over Text)

These should come with:

  • "functor parameters" (ordering, hash functions) passed only to the constructor,
  • iterators for keys, values, entries (key-value pairs),
  • an object-oriented interface.
@rossberg rossberg added the feature New feature or request label Nov 10, 2019
@matthewhammer
Copy link
Contributor

@rossberg thanks for this list; LGTM.

I'll prioritize items from here during this month and next.

@matthewhammer matthewhammer self-assigned this Nov 13, 2019
This was referenced Nov 13, 2019
@matthewhammer
Copy link
Contributor

Some things above (functional unordered maps) have been implemented, but not yet wrapped with a higher-level interface that avoids the programmer providing the hash function for each call.

Many things above are not implemented, though. None of them should be tricky, since they are all well-understood things (just not yet expressed in Motoko).

I have a rough dependency order in mind:

Imperative hash table:

Based on these ingredients, a simple hash table should be routine to implement in Motoko.

Red-black trees:

For the purely-functional version, I would follow my notes of the Okaski treatment of these. I taught them at some point recently (to undergrads, in Elm), so it shouldn't be hard to reproduce in Motoko.

Wrappers / Iterators

I think I can envision the wrappers and iterators mentioned above, though I need to work each out to be sure of the details.

@ghost ghost added this to the Post-Launch Priorities milestone Nov 19, 2019
@rossberg rossberg added the P2 medium priority, resolve within a couple of milestones label Apr 29, 2020
@kritzcreek
Copy link
Contributor

I think we've got all those data structures in base now. Can we close this @matthewhammer?

@crusso crusso mentioned this issue Apr 4, 2023
79 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feature New feature or request P2 medium priority, resolve within a couple of milestones
Projects
None yet
Development

No branches or pull requests

3 participants