
--- Ketil Malde
I think you're saying we might need a bag to hold items where we want to group things according to (equivalence on) some arbitrary key? Perhaps we could have the bag datatype parametrised over a user-supplied ordering, so that
Set a
would be equivalent to a
Bag compare a (with compare :: a -> a -> Ordering)
The bag could then hold regular (Eq-based) Sets of items.
Would this make sense? Would it be useful?
I'm not sure that I understand either :) Let me give an example...
type MyString = MyString String
instance Eq MyString where (MyString x) == (MyString y) = length x == length y
ms = MyString
Bag.toString $ Bag.fromString $ [ms "x", ms "y"]
should return the original list, [ms "x", ms "y"].
MultiSet.toString $ MultiSet.fromString $ [ms "x", ms "y"]
will return [ms "x", ms "x"]. That is why I choose to keep the "MultiSet" name. If Eq is defined as structural equality, MultiSet and Bag are equivalent. Cheers, JP. __________________________________ Do you Yahoo!? Yahoo! Mail - More reliable, more storage, less spam http://mail.yahoo.com