com.jnape.palatable.lambda.monoid

## Interface Monoid<A>

- Type Parameters:
    `A` - the element type this Monoid is formed over
  All Superinterfaces:
    Applicative<Fn1<A,A>,Fn1<A,?>>, Cartesian<A,Fn1<A,A>,Fn1<?,?>>, Cocartesian<A,Fn1<A,A>,Fn1<?,?>>, Contravariant<A,Profunctor<?,Fn1<A,A>,Fn1<?,?>>>, Fn1<A,Fn1<A,A>>, Fn2<A,A,A>, Functor<Fn1<A,A>,Fn1<A,?>>, Monad<Fn1<A,A>,Fn1<A,?>>, MonadReader<A,Fn1<A,A>,Fn1<A,?>>, MonadRec<Fn1<A,A>,Fn1<A,?>>, MonadWriter<A,Fn1<A,A>,Fn1<A,?>>, Profunctor<A,Fn1<A,A>,Fn1<?,?>>, Semigroup<A>
  All Known Implementing Classes:
    And, Concat, Endo, First, Join, Last, Or, PutAll, Trivial, Union, Xor

      public interface Monoid<A>
      extends Semigroup<A>

  A `Monoid` is the pairing of a `Semigroup` with an identity element.

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default Monoid<A>` | `flip()` Flip the order of the arguments.
    `default A` | `foldLeft(A a, Iterable<A> as)` Catamorphism under this semigroup using `FoldLeft`, where the binary operator is this semigroup, and the starting accumulator is provided.
    `default <B> A` | `foldMap(Fn1<? super B,? extends A> fn, Iterable<B> bs)` Homomorphism combined with catamorphism.
    `default Lazy<A>` | `foldRight(A a, Iterable<A> as)` Catamorphism under this semigroup using `FoldRight`, where the binary operator is this semigroup, and the starting accumulator is provided.
    `A` | `identity()` The identity element of this monoid.
    `static <A> Monoid<A>` | `monoid(Semigroup<A> semigroup, A identity)` Promote a `Semigroup` to a `Monoid` by supplying an identity element.
    `static <A> Monoid<A>` | `monoid(Semigroup<A> semigroup, Fn0<A> identityFn0)`
    `default A` | `reduceLeft(Iterable<A> as)` Catamorphism under this monoid using `ReduceLeft`, where the result is the reduction, or, if empty, the identity of this monoid.
    `default A` | `reduceRight(Iterable<A> as)` Catamorphism under this monoid using `ReduceRight`, where the result is the reduction, or, if empty, the identity of this monoid.

    - ### Methods inherited from interface com.jnape.palatable.lambda.functions.Fn2

      `apply, apply, checkedApply, checkedApply, compose, contraMap, curried, curry, diMapL, discardR, fn2, fromBiFunction, toBiFunction, uncurry, widen`

    - ### Methods inherited from interface com.jnape.palatable.lambda.functions.Fn1

      `andThen, carry, cartesian, censor, choose, cocartesian, diMap, diMapR, discardL, flatMap, fmap, fn1, fromFunction, lazyZip, listens, local, pure, pureFn1, thunk, toFunction, trampolineM, zip, zip`

    - ### Methods inherited from interface com.jnape.palatable.lambda.monad.Monad

      `join`

    - ### Methods inherited from interface com.jnape.palatable.lambda.functor.Functor

      `coerce`

- - ### Method Detail

    - #### identity

          A identity()

      The identity element of this monoid.
      Returns:
        the identity

    - #### reduceLeft

          default A reduceLeft(Iterable<A> as)

      Catamorphism under this monoid using `ReduceLeft`, where the result is the reduction, or, if empty, the identity of this monoid.
      Parameters:
        `as` - the elements to reduce
      Returns:
        the reduction, or `identity()` if empty
      See Also:
        `ReduceLeft`

    - #### reduceRight

          default A reduceRight(Iterable<A> as)

      Catamorphism under this monoid using `ReduceRight`, where the result is the reduction, or, if empty, the identity of this monoid.
      Parameters:
        `as` - an Iterable of elements in this monoid
      Returns:
        the reduction, or `identity()` if empty
      See Also:
        `ReduceRight`

    - #### foldMap

          default <B> A foldMap(Fn1<? super B,? extends A> fn,
                                Iterable<B> bs)

      Homomorphism combined with catamorphism. Convert an `Iterable<B>` to an `Iterable<A>` (that is, an `Iterable` of elements this monoid is formed over), then reduce the result from left to right. Under algebraic data types, this is isomorphic to a flatMap.
      Type Parameters:
        `B` - the input Iterable element type
      Parameters:
        `fn` - the mapping function from A to B
        `bs` - the Iterable of Bs
      Returns:
        the folded result under this Monoid
      See Also:
        `Map`, `reduceLeft(Iterable)`

    - #### foldLeft

          default A foldLeft(A a,
                             Iterable<A> as)

      Catamorphism under this semigroup using `FoldLeft`, where the binary operator is this semigroup, and the starting accumulator is provided.
      Specified by:
        `foldLeft` in interface `Semigroup<A>`
      Parameters:
        `a` - the starting accumulator
        `as` - the elements to fold over
      Returns:
        the folded result
      See Also:
        `FoldLeft`

    - #### foldRight

          default Lazy<A> foldRight(A a,
                                    Iterable<A> as)

      Catamorphism under this semigroup using `FoldRight`, where the binary operator is this semigroup, and the starting accumulator is provided.
      Specified by:
        `foldRight` in interface `Semigroup<A>`
      Parameters:
        `a` - the starting accumulator
        `as` - the elements to fold over
      Returns:
        the folded result
      See Also:
        `FoldRight`

    - #### flip

          default Monoid<A> flip()

      Flip the order of the arguments.
      Specified by:
        `flip` in interface `Fn2<A,A,A>`
      Specified by:
        `flip` in interface `Semigroup<A>`
      Returns:
        an `Fn2`<B, A, C>

    - #### monoid

          static <A> Monoid<A> monoid(Semigroup<A> semigroup,
                                      A identity)

      Promote a `Semigroup` to a `Monoid` by supplying an identity element.
      Type Parameters:
        `A` - the element type of this monoid
      Parameters:
        `semigroup` - the semigroup
        `identity` - the identity element
      Returns:
        the monoid

    - #### monoid

          static <A> Monoid<A> monoid(Semigroup<A> semigroup,
                                      Fn0<A> identityFn0)