containers
containers copied to clipboard
Data.Set add unionsWith
Like Data.Map.unionsWith.
So instead of:
Set.unions . fmap f $ setsInSets
You can:
Set.unionsWith f $ setsInSets
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 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, 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.
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 What's the type of the proposed Data.Set.unionsWith
function?