Comments (3)
Hi @theamytran,
So it sounds like your proposal is something like this?
trait Annihilating[A] {
def combine(x: A, y: A): A
def annihilator: A
}
// and then elsewhere
class AnnihilatingForSet[A: Semigroup] extends Annihilating[Set[A]] {
def combine(x: Set[A], y: Set[A]): Set[A] = x & y
def annihilator: Set[A] = Set.empty[A]
}
val x = Set(1,2,3)
val y = Set.empty[Int]
AnnihilatingForSet[Int].combine(x, y) // returns Set()
Currently it would be possible to do something similar by defining a Semiring[Set[A]]
using empty sets, unions, and intersections (which we currently have: https://github.com/typelevel/algebra/blob/master/core/src/main/scala/algebra/instances/set.scala#L26).
I guess I have a few questions for the group:
- 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]]
.
from algebra.
Here's another use case: interval intersection. https://gist.github.com/kenbot/1c37f10cd2ac8de2e988
from algebra.
IntervalSets can also have Semirings
as a note.
@theamytran do you have an algorithm in mind that you would write that uses a annihilation in the abstract?
from algebra.
Related Issues (20)
- add Kleene Algebra HOT 1
- fromInt and Ring-like structures.
- ConicMonoid: when values are always increasing. HOT 10
- Publish a version for cats 0.8.0 HOT 1
- cast class exception using algebra with algebird HOT 1
- Add tests for the functions in companion objects of the types. HOT 1
- Publish 0.7.0 to address binary incompatibility HOT 1
- Algebra Syntax (was #78 Symbolic Infix Operators)
- link to docs is broken HOT 5
- Why don't we move Spire's Module/VectorSpace/MetricSpace/etc. here? HOT 3
- Possible compatibility breaking change in cats-kernel HOT 1
- Upgrade to Cats RC1 HOT 2
- Law testing guidelines HOT 1
- Broken links in README.md HOT 2
- Integrating cats.kernel.Semigroup and friends HOT 30
- publish for Scala 2.13.0-M5 HOT 26
- publish for Scala 2.13 HOT 1
- Integrate intermediate steps between `CommutativeRing` and `Field` HOT 1
- Archive this repo? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from algebra.