User-selectable hashes for hana::map
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 225
- PR merge metrics
- No merged PRs in 30d
Description
I am currently implementing a container that models elements in polynomial rings. To this end, it makes sense to use a `hana::map` providing a mapping from tuples of _variables_ to _coefficients_ (in the mathematical sense, we have chosen a basis). Now, the most reasonable way of implementing tuples of variables is to put variables into a `hana::tuple`, but these cannot be used as keys of a `hana::map` because they are not `Hashable`.
What is the rationale for not making `hana::tuple` `Hashable`? I suspect, because there would be many ways to do so and in different contexts, different ways might be superior. Hence, I also do not want to roll my own hashing function and essentially make it the only one available.
This is probably a general issue though! Thus, to me it makes sense to allow a user to _choose_ which hashing function to use, in the case there are multiple to choose from.
Granted, this does not play well with the current interface. Hence, it might be a bad idea after all!
Another solution to my issues would be to roll my own tuple or to provide specializations to `hana::tuple`s containing my specific kind of elements. Both of these ideas are bad, though, because they just obfuscate things. Also, quite an amount of code is required to make a user-defined type a `Sequence` or `MonadPlus` (as in my case). Thus wrapping the tuple or the elements amounts to big code chunks for just getting a hashing function to work :/
Contributor guide
Research direction
Start by reading the hana::map and hana::tuple APIs and the Hashable concept to understand how keys and hashing are currently defined. The issue needs an agreed design for user-selectable hashing before implementation can be considered complete; the desired result is a documented, tested interface that supports tuple keys without forcing one hashing strategy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100