Proposal: containers: add indexing operations for Set
Thomas Schilling
nominolo at googlemail.com
Wed Jul 4 11:02:59 CEST 2012
On 3 July 2012 20:10, Patrick Palka <patrick at parcs.ath.cx> wrote:
> I'd like to add the following indexing operations for Data.Set.Set, to
> complement the existing functions for Data.Map.Map:
>
> findIndex :: Ord a => a -> Set a -> Int
> lookupIndex :: Ord a => a -> Set a -> Maybe Int
> elemAt :: Int -> Set a -> a
> deleteAt :: Int -> Set a -> Set a
I'm surprised that these functions already exists in Data.Map. What
are the use cases? I assume the only sensible semantics is to behave
as a slightly more efficient version of the same function working on
"Set.toList set" which must be ordered. I don't think that breaks any
abstractions, but they do seem like very weird functions to have.
Something that I might consider potentially useful function would be a
variant of splitAt, so that you could split a set using a fixed ratio
(e.g., "splitAt (Set.size set `div` 2) set").
So far, -1
/ Thomas
More information about the Libraries
mailing list