-
Notifications
You must be signed in to change notification settings - Fork 99
Add general merge API #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This should be the right type, no? merge :: (Hashable k, Eq k)
=> SimpleWhenMissing k a c -- ^ What to do with keys in @m1@ but not @m2@
-> SimpleWhenMissing k b c -- ^ What to do with keys in @m2@ but not @m1@
-> SimpleWhenMatched k a b c -- ^ What to do with keys in both @m1@ and @m2@
-> HashMap k a
-> HashMap k b
-> HashMap k c Could the merge strategies ( |
That's the general idea. You'll probably want to look at the |
@BebeSparkelSparkel would you possibly be interested in working on this? |
I am concerned about the the performance of |
@BebeSparkelSparkel Note that Do you have a more efficient implementation in mind? |
I doubt a much more generally efficient implementation of |
I was mistaken. #240 details It seems to me like #226 and #240 are not addressing the same problem. |
I think I'll give |
@svenkeidel I have started working on I'd be very happy if you would take this over and implement I'm curious about your usecase though! Does the order in which we sequence effects matter? I wasn't sure whether we could do anything better than keeping it completely arbitrary and unspecified. |
I need to combine two maps, while simultaneously finding out if a key in one of the maps was missing or one of the values in the resulting map has changed (https://github.com/svenkeidel/sturdy/blob/master/lib/src/Data/Abstract/Map.hs#L57-L67). More generally, I think the order of map entries should not matter since hashmaps are inherently unordered, hence the name of the library. If users rely on a predictable order of entries within the map, they have to use a different datastructure. |
@oberblastmeister, how would you like to tackle this challenge while merging mechanics are still fresh in your mind? |
@treeowl yes I would like to do this, but maybe after I do |
If you think that'll help you prepare! Another option would be to use |
Yeah I think I'll use |
I'd feel more comfortable about adding functions like |
Are we planning to make |
|
Woops, I must have clicked the wrong one |
Data.Map
andData.IntMap
offermerge
andmergeA
operations that can take unions, intersections, differences, etc. We should be able to do something quite similar here. I suspect optimalmerge
will have to be a bit different frommergeA
rather than just a specialization, thanks to the way arrays work. Also, as I've explored in a slightly different context,mergeA
can probably be implemented particularly efficiently for certain transformer stacks on top ofIO
orST s
, again thanks to the mutable array business. Dunno if that sort of thing is worth bothering with.The text was updated successfully, but these errors were encountered: