Semigroup
A semigroup is any set A with an associative operation (combine). --Scala Cats
trait Semigroup[A] {
def combine(x: A, y: A): A
}
Monoid
A monoid is a semigroup with an identity. A monoid is a specialization of a semigroup, so its operation must be associative. Additionally, combine(x, empty) == combine(empty, x) == x. For example, if we have Monoid[String], with combine as string concatenation, then empty = "". --Scala Cats
trait Monoid[A] extends Semigroup[A] {
def empty: A
}
Functors
Functor.
The name is shorts for "covariant functor".
Must obey the laws defined in cats.laws.FunctorLaws.--Scala Cats
trait Functor[F[_]] {
def map[A, B](fa: F[A])(f: A => B): F[B]
}
Monads
Monad.
Allows composition of dependent effectful functions.
See: Monads for functional programming
Must obey the laws defined in cats.laws.MonadLaws.
trait Monad[F[_]] extends Functor[F] {
def pure[A](value: A): F[A]
def flatMap[A, B](fa: F[A])(f: A => F[B]): F[B]
}