Interface Semigroup<A>

Type Parameters:
A - The element type this Semigroup 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<?,?>>
All Known Subinterfaces:
Monoid<A>
All Known Implementing Classes:
And, Concat, Endo, First, Intersection, Join, Last, Max, MergeHMaps, Min, Or, PutAll, Trivial, Union, Xor
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Semigroup<A> extends Fn2<A,A,A>
A Semigroup is a closed, associative category. As closure can be implied by the type signature, and associativity is not enforceable, this is simply represented as a binary operator.
  • Method Details

    • 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.
      Parameters:
      a - the starting accumulator
      as - the elements to fold over
      Returns:
      the folded result
      See Also:
    • 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.
      Parameters:
      a - the starting accumulator
      as - the elements to fold over
      Returns:
      the folded result
      See Also:
    • flip

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