Adapton/adapton.rust

Can't store hashmaps of names in cells; Name could implement Ord

cormacrelf opened this issue · 1 comments

  1. You can't store a HashMap in a cell, because HashMap does not implement Hash.
  2. You could store a BTreeMap<T> in a cell, if T: Ord, because BTreeMap does implement Hash.
  3. Name does not implement Ord
  4. So you cannot store a map or set of Names in a cell.

It could, as a basic and very efficient implementation, implement Ord using the precomputed hash value. Then you could put a BTreeMap/BTreeSet in a cell! Edit: no, because Ord has to agree with PartialEq/Eq when Ordering::Equal.

I've thought about this some more and I think if you want sets or maps of cells in your cells e.g. Art<BTreeSet<Art<T>>>, use a dual of string-based adapton::Names + a string interner like https://lib.rs/crates/string-interner, and carry around a wrapper type that implements PartialEq/Eq/PartialOrd/Ord based only on the interned symbol (for that crate, it's a u32).

Then, with Named { symbol: DefaultSymbol, cell: Art<T> } in hand, use BTreeSet<Named<T>>.