Add Int index functions to Data.Set
Data.Map has some functions that allow a Map's entries to be accessed through Int indexes:
lookupIndex :: Ord k => k -> Map k a -> Maybe Int
findIndex :: Ord k => k -> Map k a -> Int
elemAt :: Int -> Map k a -> (k, a)
updateAt :: (k -> a -> Maybe a) -> Int -> Map k a -> Map k a
deleteAt :: Int -> Map k a -> Map k a
With the exception of updateAt, these functions are trivially adaptable to Data.Set.
I attach a patch to this ticket that does that. My Data.Set implementations of the functions are modeled on the ones from Data.Map. Functions implemented:
lookupIndex :: Ord a => a -> Set a -> Maybe Int
findIndex :: Ord a => a -> Set a -> Int
elemAt :: Int -> Set a -> a
deleteAt :: Int -> Set a -> Set a
Trac metadata
Trac field | Value |
---|---|
Version | 7.0.3 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries (other) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |