Trait/Object

zio.prelude

Associative

Related Docs: object Associative | package prelude

Permalink

trait Associative[A] extends AnyRef

The Associative[A] type class describes an associative binary operator for a type A. For example, addition for integers, and string concatenation for strings.

Associative is at the top of the hierarchy for abstracting over operations to combine types because while there are some operations that are not associative but do obey other laws, it is generally difficult to combine more than two values in interesting ways with these operators, and thus to build solutions to more complicated problems out of solutions to simpler ones.

For example, the mean of two numbers is an operation that is commutative but not associative. However, the lack of associativity is an indication that we can't combine the means of multiple values in an interesting way with this definition. If we attempt to take the mean of three values we always place twice as much weight on one number as the others, which is rarely what we want.

If we instead define this operation using a StatsCounter object then means can be combined in ways that are associative, commutative, and have an identity element, supporting much more interesting modes of composition.

Self Type
Associative[A]
Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Associative
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def combine(l: ⇒ A, r: ⇒ A): A

    Permalink

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def intersperse(middle: A): Associative[A]

    Permalink
  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. def multiplyOption(n: Int)(a: A): Option[A]

    Permalink
  14. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. final def repeat(a: A)(n: Int): A

    Permalink
  18. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  19. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  20. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped