Equivalent to join(map(fa)(f))
.
Equivalent to join(map(fa)(f))
.
Nondeterministically sequence fs
, collecting the results using a Monoid
.
Nondeterministically sequence fs
, collecting the results using
a commutative Monoid
.
Flipped variant of ap
.
Flipped variant of ap
.
Alias for map
.
Alias for map
.
Obtain results from both a
and b
, nondeterministically ordering
their effects.
A commutative operation which chooses nondeterministically to obtain
a value from either a
or b
.
A commutative operation which chooses nondeterministically to obtain
a value from either a
or b
. If a
'wins', a 'residual' context
for b
is returned; if b
wins, a residual context for a
is
returned. The residual is useful for various instances like Future
,
which may race the two computations and require a residual to ensure
the result of the 'losing' computation is not discarded.
This function can be defined in terms of chooseAny
or vice versa.
The default implementation calls chooseAny
with a
two-element list and uses the Functor
for F
to fix up types.
A commutative operation which chooses nondeterministically to obtain
a value from any of the elements of as
.
A commutative operation which chooses nondeterministically to obtain
a value from any of the elements of as
. In the language of posets, this
constructs an antichain (a set of elements which are all incomparable) in
the effect poset for this computation.
None
, if the input is empty.
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
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
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
Filter l
according to an applicative predicate.
Filter l
according to an applicative predicate.
An Applicative
for F
in which effects happen in the opposite order.
An Applicative
for F
in which effects happen in the opposite order.
Twin all A
s in fa
.
Twin all A
s in fa
.
Pair all A
s in fa
with the result of function application.
Pair all A
s in fa
with the result of function application.
Nondeterministically gather results from the given sequence of actions.
Nondeterministically gather results from the given sequence of actions.
This function is the nondeterministic analogue of sequence
and should
behave identically to sequence
so long as there is no interaction between
the effects being gathered. However, unlike sequence
, which decides on
a total order of effects, the effects in a gather
are unordered with
respect to each other.
Although the effects are unordered, we ensure the order of results
matches the order of the input sequence. Also see gatherUnordered
.
Nondeterministically gather results from the given sequence of actions.
Nondeterministically gather results from the given sequence of actions.
The resulting list will be arbitrarily reordered, depending on the order
results come back in a sequence of calls to chooseAny
.
To preserve the order of the output list while allowing nondetermininstic
ordering of effects, use gather
.
if
lifted into a binding.
if
lifted into a binding. Unlike lift3((t,c,a)=>if(t)c else
a)
, this will only include context from the chosen of ifTrue
and ifFalse
, not the other.
Sequence the inner F
of FFA
after the outer F
, forming a
single F[A]
.
Sequence the inner F
of FFA
after the outer F
, forming a
single F[A]
.
Lift f
into F
.
Lift f
into F
.
Lift f
into F
and apply to F[A]
.
Lift f
into F
and apply to F[A]
.
Apply a function to the results of a
and b
, nondeterminstically
ordering their effects.
Lift apply(a)
, and apply the result to f
.
Lift apply(a)
, and apply the result to f
.
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
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
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
Performs the action n
times, returning the list of results.
Performs the action n
times, returning the list of results.
Performs the action n
times, returning nothing.
Performs the action n
times, returning nothing.
Inject a
to the left of B
s in f
.
Inject a
to the left of B
s in f
.
Inject b
to the right of A
s in f
.
Inject b
to the right of A
s in f
.
Empty fa
of meaningful pure values, preserving its
structure.
Empty fa
of meaningful pure values, preserving its
structure.
(Since version 7) given F: Apply[F]
use F(a,b)(f)
instead, or given implicitly[Apply[F]]
, use ^(a,b)(f)
(Since version 7) given F: Apply[F]
use F(a,b,c)(f)
instead, or given implicitly[Apply[F]]
, use ^(a,b,c)(f)
(Since version 7) given F: Apply[F]
use F(a,b,c,d)(f)
instead, or given implicitly[Apply[F]]
, use ^(a,b,c,d)(f)
scalaz.Zip derived from tuple2
.
scalaz.Zip derived from tuple2
.
(Since version 7.1.0) Apply#zip produces unlawful instances
A context supporting nondeterministic choice. Unlike
Monad.bind
, which imposes a total order on the sequencing of effects throughout a computation, thechoose
andchooseAny
operations let us partially order the sequencing of effects. Canonical instances areconcurrent.Future
andconcurrent.Task
, which run their arguments in parallel, returning whichever comes back 'first'.TODO - laws