Re: [Haskell] duplicate elements in Data.Set

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [Haskell] duplicate elements in Data.Set

Jean-Philippe Bernardy
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 <[hidden email]> 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
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell
>
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: [Haskell] duplicate elements in Data.Set

Walter Moreira
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 <[hidden email]> 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
>> [hidden email]
>> http://www.haskell.org/mailman/listinfo/haskell
>>
>

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries