[GHC] #5162: Add Int index functions to Data.Set
GHC
cvs-ghc at haskell.org
Thu Apr 28 16:25:36 CEST 2011
#5162: Add Int index functions to Data.Set
---------------------------------+------------------------------------------
Reporter: sacundim | Owner:
Type: feature request | Status: new
Priority: normal | Component: libraries (other)
Version: 7.0.3 | Keywords: Data.Set
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
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
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5162>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list