1use std::fmt::Debug;
3
4pub trait Commutative {}
6
7pub trait Action: Debug + Clone {
11 type Target: Clone;
13 fn id_action() -> Self;
15 fn composition(&mut self, rhs: &Self);
18 fn apply(&self, target: &mut Self::Target);
20}
21
22pub trait Monoid: Debug {
24 type Target: Debug + Clone;
26 fn id_element() -> Self::Target;
28 fn binary_operation(a: &Self::Target, b: &Self::Target) -> Self::Target;
30}
31
32pub trait ActionMonoid {
35 type M: Monoid;
37 type A: Action<Target = <Self::M as Monoid>::Target>;
39}
40
41pub trait IdempotentMonoid: Monoid {}
45
46pub trait Group: Monoid {
49 fn inverse(a: &Self::Target) -> Self::Target;
50}
51
52pub trait Semiring: Debug + Clone + Eq {
58 type Target: Debug + Clone + Eq;
59 fn zero() -> Self::Target;
60 fn one() -> Self::Target;
61 fn add_assign(a: &mut Self::Target, b: &Self::Target);
62 fn mul(a: &Self::Target, b: &Self::Target) -> Self::Target;
63}