jyp_7 at yahoo.com
Tue Mar 16 06:03:41 EST 2004
--- Ketil Malde <ketil+haskell at ii.uib.no> wrote:
> 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 ->
> The bag could then hold regular (Eq-based) Sets of
> 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
> 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",
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.
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
More information about the Libraries