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

Stefan Holdermans stefan at vectorfabrics.com
Mon Apr 23 15:18:04 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.

> empty' = insert () $ delete () empty
> 
> but:
> 
> empty' <> delete () empty == empty'
> 
> while:
> 
> empty <> delete () empty == delete () empty
> 
> (I couldn't test it as I don't have base 4.5, so I hope I didn't make a mistake here.)

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

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

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

Cheers,

  Stefan


More information about the Haskell-Cafe mailing list