Skip to content

Make HashMap interface compatible with Data.Map from containers #172

@m-renaud

Description

@m-renaud

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
  • 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:

If you agree these (or a subset of these) should be added I can put together some pull requests adding them. WDYT?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions