Re: [Haskell] duplicate elements in Data.Set

I'd say your compare function isn't transitive.
If you can tell it's well behaved, and if you can send me even your
complicated example, I'll look into it.
Cheers,
JP.
On 1/21/06, Walter Moreira
Hello list. Are there situations where a set can contain duplicate elements?
I have a newtype and it is an instance of 'Eq' via the 'compare' method, and it is also an instance of 'Ord'. After some Data.Set operations with sets of that type I get a set which contains two elements which compare equal. What am I doing wrong?
The function 'Set.valid' returns 'False' when applied to the set. I use the function 'Set.fromList' sometimes. Is it supposed to always yield a valid set? or it may depend on the order or equality?
Sorry the question is a little vague. When I try to construct small examples the problem disappear.
Thanks, Walter _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell

Please, discard this question. It was my fault, the compare function was a partial order instead of a total order. Best, Walter Jean-Philippe Bernardy wrote:
I'd say your compare function isn't transitive.
If you can tell it's well behaved, and if you can send me even your complicated example, I'll look into it.
Cheers, JP.
On 1/21/06, Walter Moreira
wrote: Hello list. Are there situations where a set can contain duplicate elements?
I have a newtype and it is an instance of 'Eq' via the 'compare' method, and it is also an instance of 'Ord'. After some Data.Set operations with sets of that type I get a set which contains two elements which compare equal. What am I doing wrong?
The function 'Set.valid' returns 'False' when applied to the set. I use the function 'Set.fromList' sometimes. Is it supposed to always yield a valid set? or it may depend on the order or equality?
Sorry the question is a little vague. When I try to construct small examples the problem disappear.
Thanks, Walter _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
participants (2)
-
Jean-Philippe Bernardy
-
Walter Moreira