[Haskell-cafe] ANN: signed-multiset-0.1

Stefan Holdermans stefan at vectorfabrics.com
Mon Apr 23 16:34:26 CEST 2012


Sjoerd,

>>> This is not just about map, but it also a problem for the Monoid instance. You are basically adding an extra identity element, 0, to the max monoid, which works but is weird.

>> Still that's how union is typically defined for hybrid sets. It's what happens if want union and empty to behave as generalisations of these concepts for ordinary (multi)sets.

> Then why would you want that?

You don't have to. (SignedMultiset a, additiveUnion, empty) gives you the Monoid that you seem to have a preference for. The library supplies it through the Additive wrapper. The point is that you have a choice: different applications may ask for different monoidal structures.

>> *Data.SignedMultiset> let empty' = insert () $ delete () empty
>> 
>> *Data.SignedMultiset> empty' `union` delete () empty == empty'
>> False
>> 
>> *Data.SignedMultiset> empty `union` delete () empty == delete () empty
>> True

> Ah, I missed the check in insertMany.
> 
> What about the same with
> 
> let empty' = multiply 0 $ delete () empty

*Data.SignedMultiset> let empty' = multiply 0 $ delete () empty

*Data.SignedMultiset> empty' `union` delete () empty == empty'
True

*Data.SignedMultiset> empty `union` delete () empty == delete () empty
True

Cheers,

  Stefan


More information about the Haskell-Cafe mailing list