containers icon indicating copy to clipboard operation
containers copied to clipboard

Data.Set add unionsWith

Open codygman opened this issue 4 years ago • 5 comments

Like Data.Map.unionsWith.

So instead of:

Set.unions . fmap f $ setsInSets

You can:

Set.unionsWith f $ setsInSets

codygman avatar Oct 03 '19 18:10 codygman

The trouble for me is that I'm not at all convinced that unions or unionsWith ever deserved to exist. But if you want this, you should propose it on the libraries list.

treeowl avatar Oct 03 '19 18:10 treeowl

@treeowl I do use unions occasionally. Why should it "not exist" - is it because it is mconcat now?

@codygman I don't see the analogy from Map to Set for unionsWith. For maps, it combines values for common keys. What should it combine for sets? Do you have a use case (from actual code that you can show)?

jwaldmann avatar Oct 07 '19 15:10 jwaldmann

@jwaldmann, there's a price to having a large API—it's harder for users to get a sense of the key operations when there's a bunch of cruft around. Using foldl' directly to calculate a union of multiple sets just doesn't seem like a big deal to me, but others are free to disagree. That's why I point to the libraries list, where most decisions about containers API changes take place.

treeowl avatar Oct 07 '19 15:10 treeowl

there's a price to having a large API—it's harder for users to get a sense of the key operations when there's a bunch of cruft around. Using foldl' directly to calculate a union of multiple sets just doesn't seem like a big deal to me

@treeowl That's a good point and something I've been thinking about recently.

On Mon, Oct 7, 2019, 10:57 David Feuer [email protected] wrote:

@jwaldmann https://github.com/jwaldmann, there's a price to having a large API—it's harder for users to get a sense of the key operations when there's a bunch of cruft around. Using foldl' directly to calculate a union of multiple sets just doesn't seem like a big deal to me, but others are free to disagree. That's why I point to the libraries list, where most decisions about containers API changes take place.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/haskell/containers/issues/679?email_source=notifications&email_token=AABXEN6CSWDARBBC2MEXVDTQNNL6HA5CNFSM4I5GSOYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAQ36JI#issuecomment-539082533, or mute the thread https://github.com/notifications/unsubscribe-auth/AABXEN33D3GNAX5SLIK5SVLQNNL6HANCNFSM4I5GSOYA .

codygman avatar Oct 07 '19 16:10 codygman

@codygman What's the type of the proposed Data.Set.unionsWith function?

sjakobi avatar Jul 19 '20 13:07 sjakobi