Applicative Functor, described in Applicative Programming with Effects
Whereas a scalaz.Functor allows application of a pure function to a value in a context, an Applicative
also allows application of a function in a context to a value in a context (ap
).
It follows that a pure function can be applied to arguments in a context. (See apply2
, apply3
, ... )
Applicative instances come in a few flavours:
- All scalaz.Monads are also
Applicative
- Any scalaz.Monoid can be treated as an Applicative (see scalaz.Monoid#applicative)
- Zipping together corresponding elements of Naperian data structures (those of of a fixed, possibly infinite shape)
- See also
- Companion
- object
Type members
Classlikes
Inherited classlikes
Value members
Abstract methods
Concrete methods
The composition of Applicatives F
and G
, [x]F[G[x]]
, is an Applicative
The composition of Applicatives F
and G
, [x]F[G[x]]
, is an Applicative
An Applicative
for F
in which effects happen in the opposite order.
An Applicative
for F
in which effects happen in the opposite order.
- Definition Classes
The product of Applicatives F
and G
, [x](F[x], G[x]])
, is an Applicative
The product of Applicatives F
and G
, [x](F[x], G[x]])
, is an Applicative
Performs the action n
times, returning the list of results.
Performs the action n
times, returning the list of results.
Returns the given argument if cond
is false
, otherwise, unit lifted into F.
Returns the given argument if cond
is false
, otherwise, unit lifted into F.
Inherited methods
Sequence f
, then fa
, combining their results by function
application.
Sequence f
, then fa
, combining their results by function
application.
NB: with respect to apply2
and all other combinators, as well
as scalaz.Bind, the f
action appears to the left. So
f
should be the "first" F
-action to perform. This is in
accordance with all other implementations of this typeclass in
common use, which are "function first".
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
Add a unit to any Apply to form an Applicative.
Add a unit to any Apply to form an Applicative.
- Inherited from
- Apply
The composition of Functor F
and Bifunctor G
, [x, y]F[G[x, y]]
, is a Bifunctor
The composition of Functor F
and Bifunctor G
, [x, y]F[G[x, y]]
, is a Bifunctor
- Inherited from
- Functor
The composition of Applys F
and G
, [x]F[G[x]]
, is a Apply
The composition of Applys F
and G
, [x]F[G[x]]
, is a Apply
- Inherited from
- Apply
The composition of Functors F
and G
, [x]F[G[x]]
, is a Functor
The composition of Functors F
and G
, [x]F[G[x]]
, is a Functor
- Inherited from
- Functor
Combine fa
and fb
according to Apply[F]
with a function that discards the A
(s)
Combine fa
and fb
according to Apply[F]
with a function that discards the A
(s)
- Inherited from
- ApplyParent
Combine fa
and fb
according to Apply[F]
with a function that discards the B
(s)
Combine fa
and fb
according to Apply[F]
with a function that discards the B
(s)
- Inherited from
- ApplyParent
Repeats an applicative action infinitely
Repeats an applicative action infinitely
- Inherited from
- ApplyParent
Pair all A
s in fa
with the result of function application.
Pair all A
s in fa
with the result of function application.
- Inherited from
- Functor
The composition of Functor F and Contravariant G, [x]F[G[x]]
,
is contravariant.
The composition of Functor F and Contravariant G, [x]F[G[x]]
,
is contravariant.
- Inherited from
- Functor
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
- Inherited from
- Apply
Lift apply(a)
, and apply the result to f
.
Lift apply(a)
, and apply the result to f
.
- Inherited from
- Functor
A lawful implementation of this that is isomorphic up to the methods defined on Applicative allowing for optimised parallel implementations that would otherwise violate laws of more specific typeclasses (e.g. Monad).
A lawful implementation of this that is isomorphic up to the methods defined on Applicative allowing for optimised parallel implementations that would otherwise violate laws of more specific typeclasses (e.g. Monad).
- Inherited from
- ApplicativeParent
The product of Applys F
and G
, [x](F[x], G[x]])
, is a Apply
The product of Applys F
and G
, [x](F[x], G[x]])
, is a Apply
- Inherited from
- Apply
The product of Functors F
and G
, [x](F[x], G[x]])
, is a Functor
The product of Functors F
and G
, [x](F[x], G[x]])
, is a Functor
- Inherited from
- Functor
- Inherited from
- Apply
Empty fa
of meaningful pure values, preserving its
structure.
Empty fa
of meaningful pure values, preserving its
structure.
- Inherited from
- Functor
Functors are covariant by nature, so we can treat an F[A]
as
an F[B]
if A
is a subtype of B
.
Functors are covariant by nature, so we can treat an F[A]
as
an F[B]
if A
is a subtype of B
.
- Inherited from
- Functor
Converts ma
to a value of type F[B]
using the provided bijection.
Converts ma
to a value of type F[B]
using the provided bijection.
- Inherited from
- InvariantFunctor
Converts ma
to a value of type F[B]
using the provided isomorphism.
Converts ma
to a value of type F[B]
using the provided isomorphism.
- Inherited from
- InvariantFunctor