proposal to regularize Multiset #756
jonhnet
started this conversation in
Language design
Replies: 1 comment
-
|
Further proposal for Set:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The current pervasvie Multiset is a bit clunky and inconsistent with other libraries:
I propose the following changes:
rename Multiset to FiniteMultiset. Add a doc comment to the type explaining when one would be interested in using this restricted type: when you need to put a recursive datatype inside. I'm proposing FiniteMultiset gets the funny name because it's the exception to the convention elsewhere in the standard lib.
rename the current ::new to
::from_map, for consistency with other pervasive type APIshave
::newconstructor to accept a Function, if feasible to express & satisfy the finiteness constraint. Otherwise, just omit::newand let callers use::from_map.Introduce a Multiset that rejects recursive datatypes, allows infinite support, and whose ::new accepts a closure Function.
Multiset is just a wrapper for
Map<V, nat>; implemented in multiset_lib.rs (no axioms).Note that the inifinite-support Multiset would still only have finite multiplicities, because
natfor multiplicities is usable.Make an effort to harmonize the interfaces to Multiset and FiniteMultiset, and harmonize them with Map/Set
Beta Was this translation helpful? Give feedback.
All reactions