Represents a type class for types T and U, both of which extend Structure, enabling addition operations between these types with specific constraints. This trait provides functionality for adding instances of type T to each other and for attempting to add instances of type U to T.
The operations are designed to work within the context of an AdditiveCommutativeMonoid, ensuring that the defined addition operations respect the algebraic properties of associativity, commutativity, and identity.
CONSIDER could we do without the U type parameter.
Type Parameters:
T: A type extending Structure that supports addition operations and satisfies the properties of an additive commutative monoid.
U: A type extending Structure that is potentially compatible with T in certain addition operations.
Returns the zero value of type T. This value serves as the identity element for the addition operation of T.
Returns the zero value of type T. This value serves as the identity element for the addition operation of T.
Attributes
Returns
The zero value of type T.
Concrete methods
def +(that: U)(using AdditiveCommutativeMonoid[T], Convertible[T, U]): T
Adds the given instance of the same type to this instance, leveraging the properties of an AdditiveCommutativeMonoid to ensure associativity, commutativity, and identity. CONSIDER keeping percentage if both are percentages. CONSIDER rewriting this in such a way that no exception will ever be thrown (use compiler to check, not runtime).
Adds the given instance of the same type to this instance, leveraging the properties of an AdditiveCommutativeMonoid to ensure associativity, commutativity, and identity. CONSIDER keeping percentage if both are percentages. CONSIDER rewriting this in such a way that no exception will ever be thrown (use compiler to check, not runtime).
Value parameters
that
The instance of the same type to be added to this instance.
Attributes
Returns
The result of adding this instance and the provided instance.
Computes the addition of this object and the given Structure object using the additive properties of an AdditiveCommutativeMonoid. The operation returns an optional result where the addition succeeds if a valid transformation and combination can be performed.
Computes the addition of this object and the given Structure object using the additive properties of an AdditiveCommutativeMonoid. The operation returns an optional result where the addition succeeds if a valid transformation and combination can be performed.
CONSIDER eliminate this method and use with + instead.
Value parameters
that
the Structure object to be added to this object.
Attributes
Returns
an Option containing the result of the addition if successful, or None if the operation cannot be completed.
Casts the current instance to the type parameter T of the enclosing Can trait.
Casts the current instance to the type parameter T of the enclosing Can trait.
This method performs a type-safe cast using the ClassTag to verify at runtime that the cast is valid. If the current instance cannot be cast to type T, an AlgebraException is thrown.