Proposal: add Int indexing functions to Data.Set

Ivan Lazar Miljenovic ivan.miljenovic at
Fri Apr 29 07:42:33 CEST 2011

On 29 April 2011 15:33, Luis Casillas <luis at> wrote:
> El abr 28, 2011, a las 9:16 p.m., Ivan Lazar Miljenovic escribió:
>> On 29 April 2011 14:08, Luis Casillas <luis at> wrote:
>>> 2. Concern that Int-based indexing breaks the set abstraction by exposing a specific ordering (Trac comment by Malcolm Wallace).  My assumption when I decided to submit this patch was that if it's OK for Data.Map to have these operations, then it should also be ok for Data.Set to have them.  But Malcolm's concern makes me wonder if some people will find the original Data.Map functions objectionable and dislike the idea of "spreading the infection" to Data.Set.
>> I think I agree with Malcolm here; the internals of Data.Set shouldn't
>> be revealed IMHO.
> Would either of the following modifications make the proposal more palatable?
> 1. Stressing in the functions' documentation that the assignment of Ints does not have to reflect the order of the elements.  The examples would also be rewritten not to make any ordering assumptions.
> 2. Modifying the implementation to scramble the order of the indexes relative to the order of the set elements.  This would discourage people from implicitly coding to the element order.
> I'm not at all committed to having the order of the indexes reflect the order of the set members or any specific internal property of the set implementation.  I'm happy with any one-to-one, reversible mapping between sets and Ints in the range [0..(size-1)].  I'm also happy if the mapping changes between library versions (or heck, even between different invocations of the same program).

Well, before we talk about modifications, etc.: is there a _need_ for
this kind of indexing in a Set?

Ivan Lazar Miljenovic
Ivan.Miljenovic at

More information about the Libraries mailing list