You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.
I'm interested in such a type class included here. A sample use case would be set intersection: consider the following pieces of code, reflecting use of a Monoid[Option[?]].
Hypothetical monoid
implicitobjectIntSetIntersectionMonoidextendsMonoid[Set[Int]] {
defappend(a: Set[Int], b: =>Set[Int]):Set[Int] = a intersect b
defidentity=// the universe. This is impossible, which is why we need the annihilator to existdefzero=Set()
}
Existing monoid:
vala=Set(1, 2).some
valb= none
a |+| b // returns Set(1, 2)
With annihilation:
vala=Set(1, 2).some
valb= none
a |*| b // returns empty set
There are possibly many other examples other than set intersection that may be useful. Also, apologies if anything is unclear. This is my first time using GitHub issues. Thanks!
The text was updated successfully, but these errors were encountered:
Does anyone know of any algorithms or structures that need only multiplication and zero?
How often do people encounter semigroups which can't be monoids but could be annihilators?
Would it make more sense to put this in the semigroup hierarchy or keep it alone?
My 2¢ is that it seems reasonable to add AnnihilatingSemigroup (and AnnihilatingMonoid) if we can think of more use cases that would benefit from having them. The set example is less compelling to me only because we already have Semiring[Set[A]].
There is a concept called the Annihilator (wikipedia) which basically defines the multiplicative zero of a set. Here's a blog post that shows an example Annihilator: http://underscore.io/blog/posts/2015/07/02/annihilators-in-scala.html
I'm interested in such a type class included here. A sample use case would be set intersection: consider the following pieces of code, reflecting use of a Monoid[Option[?]].
Hypothetical monoid
Existing monoid:
With annihilation:
There are possibly many other examples other than set intersection that may be useful. Also, apologies if anything is unclear. This is my first time using GitHub issues. Thanks!
The text was updated successfully, but these errors were encountered: