FreeAbGroup

final
class FreeAbGroup[A] extends AnyVal
Companion
object
class AnyVal
trait Matchable
class Any

Value members

Concrete methods

def run[B](f: A => B)(implicit B: CommutativeGroup[B]): B

Maps the terms using f to type B and sums their results using the AbGroup for B.

Maps the terms using f to type B and sums their results using the AbGroup for B.

def runMonoid[B](f: A => B)(implicit B: CommutativeMonoid[B]): Option[B]

As long as there are no negative terms, this maps the terms using f, then sums the results using the CMonoid for B. If there is a negative term, then None is returned.

As long as there are no negative terms, this maps the terms using f, then sums the results using the CMonoid for B. If there is a negative term, then None is returned.

def runSemigroup[B](f: A => B)(implicit B: CommutativeSemigroup[B]): Option[B]

As long as there are no negative terms and at least 1 positive term, this maps the terms using f, then sums the results using the CSemigroup for B. If there is a negative term, or if there are no terms at all, then None is returned.

As long as there are no negative terms and at least 1 positive term, this maps the terms using f, then sums the results using the CSemigroup for B. If there is a negative term, or if there are no terms at all, then None is returned.

def split[B](f: A => B)(implicit B: CommutativeMonoid[B]): (B, B)

Sums up the results of the negative and positive terms separately, using f to map the terms to type B and using its CMonoid. This returns a tuple with the sum of the negative terms on the left and the sum of the positive terms on the right.

Sums up the results of the negative and positive terms separately, using f to map the terms to type B and using its CMonoid. This returns a tuple with the sum of the negative terms on the left and the sum of the positive terms on the right.

def splitSemigroup[B](f: A => B)(implicit B: CommutativeSemigroup[B]): (Option[B], Option[B])

Sums up the results of the negative and positive terms separately, using f to map the terms to type B and using its CSemigroup. This returns a tuple with the sum of the negative terms on the left and the sum of the positive terms on the right. If either side has no terms at all, then that side is None.

Sums up the results of the negative and positive terms separately, using f to map the terms to type B and using its CSemigroup. This returns a tuple with the sum of the negative terms on the left and the sum of the positive terms on the right. If either side has no terms at all, then that side is None.

override
def toString: String
Definition Classes
Any
def |+|(rhs: FreeAbGroup[A]): FreeAbGroup[A]
def |-|(rhs: FreeAbGroup[A]): FreeAbGroup[A]

Concrete fields

val terms: Map[A, Int]