Conversation
|
I don't remember who wrote the current code for |
|
I'm not sure I see how the Personally I don't think the |
|
Good point. We probably should discuss the |
1bf4209 to
cbd43ab
Compare
cbd43ab to
16ed390
Compare
|
@treeowl any more comments on this? |
16ed390 to
0066089
Compare
Add Data.Set.Merge to allow merging sets, similar to Data.Map.Merge.Lazy and Data.Map.Merge.Strict. To avoid the naming conflict, rename Set's `merge` to `link2` just like we have for Map.
0066089 to
419eded
Compare
| merge | ||
| :: Ord a | ||
| => SimpleWhenMissing a -- ^ What to do with elements in @s1@ but not @s2@ | ||
| -> SimpleWhenMissing a -- ^ What to do with elements in @s2@ but not @s1@ | ||
| -> SimpleWhenMatched a -- ^ What to do with elements in both @s1@ and @s2@ | ||
| -> Set a -- ^ Set @s1@ | ||
| -> Set a -- ^ Set @s2@ | ||
| -> Set a |
There was a problem hiding this comment.
Just from a Developer Experience perspective, would the following be a good idea?
merge
:: Ord a
=> (Set a, SimpleWhenMissing a)
-- ^ @s1@ and what to do with elements that are not in @s2@
-> (Set a, SimpleWhenMissing a)
-- ^ @s2@ and what to do with elements that are not in @s1@
-> SimpleWhenMatched a -- ^ What to do with elements in both @s1@ and @s2@
-> Set aThere was a problem hiding this comment.
Worth considering, but I would say the current form is preferable.
(For the record, this interface is the same as in the existing Map.Merge.)
The idea is that this lets users define their merge function as
myMerge :: Ord a => Set a -> Set a -> Set a
myMerge = merge (... whenMissing1 ...) (... whenMissing2 ...) (... whenMatched ...)which they can use where they need it. The doc also refers to this:
-- When 'mergeA' is given three arguments, it is inlined at the call
-- site. To prevent excessive inlining, you should generally only use
-- 'mergeA' to define custom combining functions.
For #732