-
Notifications
You must be signed in to change notification settings - Fork 103
Description
I've recently started contributing to containers and noticed that the interface for HashMap is slightly different in some spots or missing some functions compared to Data.Map. The ones I've noticed so far are:
Missing:
(Eq k, Hashable k) constraint applies for each.
-
(!?) :: HashMap k v -> k -> Maybe v(Add operator HashMap.!? #175)- Flipped
lookup
- Flipped
-
keysSet :: HashMap k a -> HashSet k -
fromListWithKey :: (k -> a -> a -> a) -> [(k, a)] -> HashMap k a -
alterF :: (Maybe a -> f (Maybe a)) -> k -> HashMap k a -> f (HashMap k a) -
differenceWithKey :: (k -> v1 -> v2 -> v3) -> HashMap k v1 -> HashMap k v2 -> HashMap k v3
The following are unnecessary micro-optimizations or not pulling their weight and should be removed from containers:
adjustWithKey :: (k -> a -> a) -> k -> HashMap k a -> HashMap k a (#178)
insertWithKey :: (k -> a -> a -> a) -> k -> a -> HashMap k a -> HashMap k a (#177)
updateWithKey :: (k -> a -> Maybe a) -> k -> HashMap k a -> HashMap k a
notMember :: k -> HashMap k a -> Bool
IMHO the Data.Map API is too big, so there are others not present that I haven't included in the list.
Different:
-
Data.Map.findWithDefault == Data.HashMap.lookupDefault(Add HashMap.findWithDefault #176)- I propose we deprecate
lookupDefaultin favour offindWithDefault(libraries thread)
- I propose we deprecate
If you agree these (or a subset of these) should be added I can put together some pull requests adding them. WDYT?