Typeclass trait representing an algebraic structure that is a Functor[Context]
(i.e., it
declares a map
method that obeys the functor laws) augmented by insert
and applying
methods that obey laws of homomorphism and interchange.
The homomorphism law states that given a value, a
, of type A
and
a function, f
, of type A => B
(and implicit Applicative.adapters
imported):
val ca = applicative.insert(a) val cf = applicative.insert(f) ca.applying(cf) === applicative.insert(f(a))The interchange law states that given a value,
a
, of type A
and
a function, cf
, of type Context[A => B]
(and implicit Applicative.adapters
imported):
val ca = applicative.insert(a) val cg = applicative.insert((f: A => B) => f(a)) ca.applying(cf) === cf.applying(cg)
Typeclass trait representing a binary operation that obeys the associative law.
Typeclass trait representing a binary operation that obeys the associative law.
The associative law states that given values a
, b
, and c
of type A
(and implicit Associative.adapters
imported):
((a combine b) combine c) === (a combine (b combine c))
Note: In mathematics, the algebraic structure consisting of a set along with an associative binary operation is known as a semigroup.
Typeclass trait representing a binary operation that obeys the commutative law.
Typeclass trait representing a binary operation that obeys the commutative law.
The commutative law states that changing the order of the operands to a binary operation
does not change the result, i.e. given values a
, b
(a combine b) === (b combine a)
Typeclass trait representing two binary operations that obeys the distributive law:
one, dcombine
that does the distributing, and the other combine
binary combine that dcombine is applied to.
Typeclass trait representing two binary operations that obeys the distributive law:
one, dcombine
that does the distributing, and the other combine
binary combine that dcombine is applied to.
The distributive law states that given values a
, b
, c
a dcombine (b combine c) === (a dcombine b) combine (a dcombine c)
Typeclass trait representing an algebraic structure defined by a map
method that
obeys laws of identity and composition.
Typeclass trait representing an algebraic structure defined by a map
method that
obeys laws of identity and composition.
The identity law states that given a value ca
of type Context[A]
and
the identity function, (a: A) => a
(and implicit Functor.adapters
imported):
ca.map((a: A) => a) === ca
The composition law states that given a value ca
of type Context[A]
and
two functions, f
of type A => B
and g
of type B => C
(and implicit Functor.adapters
imported):
ca.map(f).map(g) === ca.map(g compose f)
Typeclass trait for algebraic structure containing insertion and flat-mapping methods that obey laws of identity and associativity.
Typeclass trait for algebraic structure containing insertion and flat-mapping methods that obey laws of identity and associativity.
A Monad
instance wraps an object that in some way behaves as a Monad
.
Typeclass trait representing a binary operation that obeys the associative law and an identity element that obeys the left and right identity laws.
Typeclass trait representing a binary operation that obeys the associative law and an identity element that obeys the left and right identity laws.
The associative law states that given values a
, b
, and c
of type A
(and implicit Monoid.adapters
imported):
((a combine b) combine c) === (a combine (b combine c))
The left identity law states that given the identity value, z
, and any other value, a
,
of type A
(and implicit Monoid.adapters
imported):
(z combine a) === a
An similarly, the right identity law states that given the same values and implicit:
(a combine z) === a
Companion object for trait Applicative
.
Companion object for trait Applicative
.
Companion object for Associative
.
Companion object for Associative
.
an implicit conversion method from A
to Associative.Adapter[A]
Companion object for Commutative
.
Companion object for Commutative
.
an implicit conversion method from A
to Commutative.Adapter[A]
Companion object for Distributive
.
Companion object for Distributive
.
an implicit conversion method from A
to Distributive.Adapter[A]
Companion object for trait Functor
.
Companion object for trait Functor
.
Companion object for Monad
typeclass.
Companion object for Monad
typeclass.
Companion object for trait Monoid
.
Companion object for trait Monoid
.
Typeclass trait representing an algebraic structure that is a
The interchange law states that given a value,Functor[Context]
(i.e., it declares amap
method that obeys the functor laws) augmented byinsert
andapplying
methods that obey laws of homomorphism and interchange. The homomorphism law states that given a value,a
, of typeA
and a function,f
, of typeA => B
(and implicitApplicative.adapters
imported):a
, of typeA
and a function,cf
, of typeContext[A => B]
(and implicitApplicative.adapters
imported):