Add CommutativeMonoid
Closed this issue · 5 comments
It might be useful to add a CommutativeMonoid superclass of Monoid. This came up in the discussion here: purescript/purescript-prelude#87. It would not introduce any new operations, but require <> to be a commutative operation.
On the other hand, I currently cannot think of any function that would make use of the CommutativeMonoid constraint 😄
Note that another option would be to add CommutativeSemigroup and let CommutativeMonoid be derived from CommutativeSemigroup and Monoid.
Commutative monoids might be useful when talking about distributing work over multiple cores, eg with web workers. CRDTs are probably relevant here too.
Sent from my iPhone
On Jul 21, 2016, at 1:48 PM, David Peter notifications@github.com wrote:
It might be useful to add a CommutativeMonoid superclass of Monoid. This came up in the discussion here: purescript/purescript-prelude#87. It would not introduce any new operations, but require <> to be a commutative operation.
On the other hand, I currently cannot think of any function that would make use of the CommutativeMonoid constraint 😄
Note that another option would be to add CommutativeSemigroup and let CommutativeMonoid be derived from CommutativeSemigroup and Monoid.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Commutative monoids might be useful when talking about distributing work over multiple cores, eg with web workers
I thought about this shortly... but wouldn't associativity be sufficient for that?
Associativity is enough to get parallelism over mappends by distributing mappends to different cores. Another model is to just mappend monoidal values as they become available. Depending on the cost and order of evaluation, that might be better (or not).
Sent from my iPhone
On Jul 21, 2016, at 2:01 PM, David Peter notifications@github.com wrote:
Commutative monoids might be useful when talking about distributing work over multiple cores, eg with web workers
I thought about this shortly... but wouldn't associativity be sufficient for that?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
Better example - suppose you have some query API with pagination like GitHub. If you want to parallelize over pages, you need to be able to ignore order if you want to output any result before you see the data for the first page.
I think generally, if you want a commutative monoid though, you probably really want some sort of lattice structure, since you will have some notion of increasing information. Maybe this belongs better in some sort of lattice library?
Sent from my iPhone
On Jul 21, 2016, at 2:01 PM, David Peter notifications@github.com wrote:
Commutative monoids might be useful when talking about distributing work over multiple cores, eg with web workers
I thought about this shortly... but wouldn't associativity be sufficient for that?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
Another model is to just mappend monoidal values as they become available. Depending on the cost and order of evaluation, that might be better (or not).
…
Better example - suppose you have some query API with pagination like GitHub. If you want to parallelize over pages, you need to be able to ignore order if you want to output any result before you see the data for the first page.
Thanks. Those make sense.
Ok, I'll close this for now. Might make more sense to add it once it's actually needed somewhere.