trait Nondeterminism[F[_]] extends Monad[F]
A context supporting nondeterministic choice. Unlike Monad.bind
,
which imposes a total order on the sequencing of effects throughout a
computation, the choose
and chooseAny
operations let us
partially order the sequencing of effects. Canonical instances are
concurrent.Future
and concurrent.Task
, which run their arguments
in parallel, returning whichever comes back 'first'.
TODO - laws
- Self Type
- Nondeterminism[F]
- Source
- Nondeterminism.scala
- Alphabetic
- By Inheritance
- Nondeterminism
- Monad
- Bind
- Applicative
- Apply
- Functor
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
trait
ApplicativeLaw
extends FunctorLaw
- Definition Classes
- Applicative
-
trait
FunctorLaw
extends AnyRef
- Definition Classes
- Functor
-
trait
MonadLaw
extends ApplicativeLaw
- Definition Classes
- Monad
Abstract Value Members
-
abstract
def
bind[A, B](fa: F[A])(f: (A) ⇒ F[B]): F[B]
Equivalent to
join(map(fa)(f))
.Equivalent to
join(map(fa)(f))
.- Definition Classes
- Bind
- abstract def chooseAny[A](head: F[A], tail: Seq[F[A]]): F[(A, Seq[F[A]])]
-
abstract
def
point[A](a: ⇒ A): F[A]
- Definition Classes
- Applicative
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
aggregate[A, M](fs: Seq[F[A]])(m: Monoid[A]): F[A]
Nondeterministically sequence
fs
, collecting the results using aMonoid
. -
def
aggregateCommutative[A, M](fs: Seq[F[A]])(m: Monoid[A]): F[A]
Nondeterministically sequence
fs
, collecting the results using a commutativeMonoid
. -
def
ap[A, B](fa: ⇒ F[A])(f: ⇒ F[(A) ⇒ B]): F[B]
Sequence
f
, thenfa
, combining their results by function application.Sequence
f
, thenfa
, combining their results by function application.NB: with respect to
apply2
and all other combinators, as well as scalaz.Bind, thef
action appears to the *left*. Sof
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". -
def
ap2[A, B, C](fa: ⇒ F[A], fb: ⇒ F[B])(f: F[(A, B) ⇒ C]): F[C]
- Definition Classes
- Apply
-
def
ap3[A, B, C, D](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C])(f: F[(A, B, C) ⇒ D]): F[D]
- Definition Classes
- Apply
-
def
ap4[A, B, C, D, E](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D])(f: F[(A, B, C, D) ⇒ E]): F[E]
- Definition Classes
- Apply
-
def
ap5[A, B, C, D, E, R](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D], fe: ⇒ F[E])(f: F[(A, B, C, D, E) ⇒ R]): F[R]
- Definition Classes
- Apply
-
def
ap6[A, B, C, D, E, FF, R](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D], fe: ⇒ F[E], ff: ⇒ F[FF])(f: F[(A, B, C, D, E, FF) ⇒ R]): F[R]
- Definition Classes
- Apply
-
def
ap7[A, B, C, D, E, FF, G, R](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D], fe: ⇒ F[E], ff: ⇒ F[FF], fg: ⇒ F[G])(f: F[(A, B, C, D, E, FF, G) ⇒ R]): F[R]
- Definition Classes
- Apply
-
def
ap8[A, B, C, D, E, FF, G, H, R](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D], fe: ⇒ F[E], ff: ⇒ F[FF], fg: ⇒ F[G], fh: ⇒ F[H])(f: F[(A, B, C, D, E, FF, G, H) ⇒ R]): F[R]
- Definition Classes
- Apply
-
def
apF[A, B](f: ⇒ F[(A) ⇒ B]): (F[A]) ⇒ F[B]
Flipped variant of
ap
.Flipped variant of
ap
.- Definition Classes
- Apply
-
def
applicativeLaw: ApplicativeLaw
- Definition Classes
- Applicative
-
val
applicativeSyntax: ApplicativeSyntax[F]
- Definition Classes
- Applicative
-
def
apply[A, B](fa: F[A])(f: (A) ⇒ B): F[B]
Alias for
map
.Alias for
map
.- Definition Classes
- Functor
-
def
apply10[A, B, C, D, E, FF, G, H, I, J, R](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D], fe: ⇒ F[E], ff: ⇒ F[FF], fg: ⇒ F[G], fh: ⇒ F[H], fi: ⇒ F[I], fj: ⇒ F[J])(f: (A, B, C, D, E, FF, G, H, I, J) ⇒ R): F[R]
- Definition Classes
- Apply
-
def
apply11[A, B, C, D, E, FF, G, H, I, J, K, R](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D], fe: ⇒ F[E], ff: ⇒ F[FF], fg: ⇒ F[G], fh: ⇒ F[H], fi: ⇒ F[I], fj: ⇒ F[J], fk: ⇒ F[K])(f: (A, B, C, D, E, FF, G, H, I, J, K) ⇒ R): F[R]
- Definition Classes
- Apply
-
def
apply12[A, B, C, D, E, FF, G, H, I, J, K, L, R](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D], fe: ⇒ F[E], ff: ⇒ F[FF], fg: ⇒ F[G], fh: ⇒ F[H], fi: ⇒ F[I], fj: ⇒ F[J], fk: ⇒ F[K], fl: ⇒ F[L])(f: (A, B, C, D, E, FF, G, H, I, J, K, L) ⇒ R): F[R]
- Definition Classes
- Apply
-
def
apply2[A, B, C](fa: ⇒ F[A], fb: ⇒ F[B])(f: (A, B) ⇒ C): F[C]
- Definition Classes
- Applicative → Apply
-
def
apply3[A, B, C, D](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C])(f: (A, B, C) ⇒ D): F[D]
- Definition Classes
- Apply
-
def
apply4[A, B, C, D, E](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D])(f: (A, B, C, D) ⇒ E): F[E]
- Definition Classes
- Apply
-
def
apply5[A, B, C, D, E, R](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D], fe: ⇒ F[E])(f: (A, B, C, D, E) ⇒ R): F[R]
- Definition Classes
- Apply
-
def
apply6[A, B, C, D, E, FF, R](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D], fe: ⇒ F[E], ff: ⇒ F[FF])(f: (A, B, C, D, E, FF) ⇒ R): F[R]
- Definition Classes
- Apply
-
def
apply7[A, B, C, D, E, FF, G, R](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D], fe: ⇒ F[E], ff: ⇒ F[FF], fg: ⇒ F[G])(f: (A, B, C, D, E, FF, G) ⇒ R): F[R]
- Definition Classes
- Apply
-
def
apply8[A, B, C, D, E, FF, G, H, R](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D], fe: ⇒ F[E], ff: ⇒ F[FF], fg: ⇒ F[G], fh: ⇒ F[H])(f: (A, B, C, D, E, FF, G, H) ⇒ R): F[R]
- Definition Classes
- Apply
-
def
apply9[A, B, C, D, E, FF, G, H, I, R](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D], fe: ⇒ F[E], ff: ⇒ F[FF], fg: ⇒ F[G], fh: ⇒ F[H], fi: ⇒ F[I])(f: (A, B, C, D, E, FF, G, H, I) ⇒ R): F[R]
- Definition Classes
- Apply
-
val
applySyntax: ApplySyntax[F]
- Definition Classes
- Apply
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
val
bindSyntax: BindSyntax[F]
- Definition Classes
- Bind
-
def
both[A, B](a: F[A], b: F[B]): F[(A, B)]
Obtain results from both
a
andb
, nondeterministically ordering their effects. -
def
choose[A, B](a: F[A], b: F[B]): F[\/[(A, F[B]), (F[A], B)]]
A commutative operation which chooses nondeterministically to obtain a value from either
a
orb
.A commutative operation which chooses nondeterministically to obtain a value from either
a
orb
. Ifa
'wins', a 'residual' context forb
is returned; ifb
wins, a residual context fora
is returned. The residual is useful for various instances likeFuture
, 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 callschooseAny
with a two-element list and uses theFunctor
forF
to fix up types. -
def
chooseAny[A](a: Seq[F[A]]): Option[F[(A, Seq[F[A]])]]
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.- returns
None
, if the input is empty.
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
compose[G[_]](implicit G0: Applicative[G]): Applicative[[α]F[G[α]]]
The composition of Applicatives
F
andG
,[x]F[G[x]]
, is an ApplicativeThe composition of Applicatives
F
andG
,[x]F[G[x]]
, is an Applicative- Definition Classes
- Applicative
-
def
compose[G[_]](implicit G0: Apply[G]): Apply[[α]F[G[α]]]
The composition of Applys
F
andG
,[x]F[G[x]]
, is a ApplyThe composition of Applys
F
andG
,[x]F[G[x]]
, is a Apply- Definition Classes
- Apply
-
def
compose[G[_]](implicit G0: Functor[G]): Functor[[α]F[G[α]]]
The composition of Functors
F
andG
,[x]F[G[x]]
, is a FunctorThe composition of Functors
F
andG
,[x]F[G[x]]
, is a Functor- Definition Classes
- Functor
-
def
counzip[A, B](a: \/[F[A], F[B]]): F[\/[A, B]]
- Definition Classes
- Functor
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
filterM[A](l: List[A])(f: (A) ⇒ F[Boolean]): F[List[A]]
Filter
l
according to an applicative predicate.Filter
l
according to an applicative predicate.- Definition Classes
- Applicative
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
flip: Applicative[F]
An
Applicative
forF
in which effects happen in the opposite order.An
Applicative
forF
in which effects happen in the opposite order.- Definition Classes
- Applicative
-
def
fpair[A](fa: F[A]): F[(A, A)]
Twin all
A
s infa
.Twin all
A
s infa
.- Definition Classes
- Functor
-
def
fproduct[A, B](fa: F[A])(f: (A) ⇒ B): F[(A, B)]
Pair all
A
s infa
with the result of function application.Pair all
A
s infa
with the result of function application.- Definition Classes
- Functor
-
def
functorLaw: FunctorLaw
- Definition Classes
- Functor
-
val
functorSyntax: FunctorSyntax[F]
- Definition Classes
- Functor
-
def
gather[A](fs: Seq[F[A]]): F[List[A]]
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 tosequence
so long as there is no interaction between the effects being gathered. However, unlikesequence
, which decides on a total order of effects, the effects in agather
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
. -
def
gatherUnordered[A](fs: Seq[F[A]]): F[List[A]]
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
. -
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
def
ifM[B](value: F[Boolean], ifTrue: ⇒ F[B], ifFalse: ⇒ F[B]): F[B]
if
lifted into a binding.if
lifted into a binding. Unlikelift3((t,c,a)=>if(t)c else a)
, this will only include context from the chosen ofifTrue
andifFalse
, not the other.- Definition Classes
- Bind
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
join[A](ffa: F[F[A]]): F[A]
Sequence the inner
F
ofFFA
after the outerF
, forming a singleF[A]
.Sequence the inner
F
ofFFA
after the outerF
, forming a singleF[A]
.- Definition Classes
- Bind
-
def
lift[A, B](f: (A) ⇒ B): (F[A]) ⇒ F[B]
Lift
f
intoF
.Lift
f
intoF
.- Definition Classes
- Functor
-
def
lift10[A, B, C, D, E, FF, G, H, I, J, R](f: (A, B, C, D, E, FF, G, H, I, J) ⇒ R): (F[A], F[B], F[C], F[D], F[E], F[FF], F[G], F[H], F[I], F[J]) ⇒ F[R]
- Definition Classes
- Apply
-
def
lift11[A, B, C, D, E, FF, G, H, I, J, K, R](f: (A, B, C, D, E, FF, G, H, I, J, K) ⇒ R): (F[A], F[B], F[C], F[D], F[E], F[FF], F[G], F[H], F[I], F[J], F[K]) ⇒ F[R]
- Definition Classes
- Apply
-
def
lift12[A, B, C, D, E, FF, G, H, I, J, K, L, R](f: (A, B, C, D, E, FF, G, H, I, J, K, L) ⇒ R): (F[A], F[B], F[C], F[D], F[E], F[FF], F[G], F[H], F[I], F[J], F[K], F[L]) ⇒ F[R]
- Definition Classes
- Apply
-
def
lift2[A, B, C](f: (A, B) ⇒ C): (F[A], F[B]) ⇒ F[C]
- Definition Classes
- Apply
-
def
lift3[A, B, C, D](f: (A, B, C) ⇒ D): (F[A], F[B], F[C]) ⇒ F[D]
- Definition Classes
- Apply
-
def
lift4[A, B, C, D, E](f: (A, B, C, D) ⇒ E): (F[A], F[B], F[C], F[D]) ⇒ F[E]
- Definition Classes
- Apply
-
def
lift5[A, B, C, D, E, R](f: (A, B, C, D, E) ⇒ R): (F[A], F[B], F[C], F[D], F[E]) ⇒ F[R]
- Definition Classes
- Apply
-
def
lift6[A, B, C, D, E, FF, R](f: (A, B, C, D, E, FF) ⇒ R): (F[A], F[B], F[C], F[D], F[E], F[FF]) ⇒ F[R]
- Definition Classes
- Apply
-
def
lift7[A, B, C, D, E, FF, G, R](f: (A, B, C, D, E, FF, G) ⇒ R): (F[A], F[B], F[C], F[D], F[E], F[FF], F[G]) ⇒ F[R]
- Definition Classes
- Apply
-
def
lift8[A, B, C, D, E, FF, G, H, R](f: (A, B, C, D, E, FF, G, H) ⇒ R): (F[A], F[B], F[C], F[D], F[E], F[FF], F[G], F[H]) ⇒ F[R]
- Definition Classes
- Apply
-
def
lift9[A, B, C, D, E, FF, G, H, I, R](f: (A, B, C, D, E, FF, G, H, I) ⇒ R): (F[A], F[B], F[C], F[D], F[E], F[FF], F[G], F[H], F[I]) ⇒ F[R]
- Definition Classes
- Apply
-
def
map[A, B](fa: F[A])(f: (A) ⇒ B): F[B]
Lift
f
intoF
and apply toF[A]
.Lift
f
intoF
and apply toF[A]
.- Definition Classes
- Monad → Applicative → Functor
-
def
mapBoth[A, B, C](a: F[A], b: F[B])(f: (A, B) ⇒ C): F[C]
Apply a function to the results of
a
andb
, nondeterminstically ordering their effects. -
def
mapply[A, B](a: A)(f: F[(A) ⇒ B]): F[B]
Lift
apply(a)
, and apply the result tof
.Lift
apply(a)
, and apply the result tof
.- Definition Classes
- Functor
-
def
monadLaw: MonadLaw
- Definition Classes
- Monad
-
val
monadSyntax: MonadSyntax[F]
- Definition Classes
- Monad
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- val nondeterminismSyntax: NondeterminismSyntax[F]
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
product[G[_]](implicit G0: Applicative[G]): Applicative[[α](F[α], G[α])]
The product of Applicatives
F
andG
,[x](F[x], G[x]])
, is an ApplicativeThe product of Applicatives
F
andG
,[x](F[x], G[x]])
, is an Applicative- Definition Classes
- Applicative
-
def
product[G[_]](implicit G0: Apply[G]): Apply[[α](F[α], G[α])]
The product of Applys
F
andG
,[x](F[x], G[x]])
, is a ApplyThe product of Applys
F
andG
,[x](F[x], G[x]])
, is a Apply- Definition Classes
- Apply
-
def
product[G[_]](implicit G0: Functor[G]): Functor[[α](F[α], G[α])]
The product of Functors
F
andG
,[x](F[x], G[x]])
, is a FunctorThe product of Functors
F
andG
,[x](F[x], G[x]])
, is a Functor- Definition Classes
- Functor
-
def
pure[A](a: ⇒ A): F[A]
- Definition Classes
- Applicative
-
def
replicateM[A](n: Int, fa: F[A]): F[List[A]]
Performs the action
n
times, returning the list of results.Performs the action
n
times, returning the list of results.- Definition Classes
- Applicative
-
def
replicateM_[A](n: Int, fa: F[A]): F[Unit]
Performs the action
n
times, returning nothing.Performs the action
n
times, returning nothing.- Definition Classes
- Applicative
-
def
sequence[A, G[_]](as: G[F[A]])(implicit arg0: Traverse[G]): F[G[A]]
- Definition Classes
- Applicative
-
def
sequence1[A, G[_]](as: G[F[A]])(implicit arg0: Traverse1[G]): F[G[A]]
- Definition Classes
- Apply
-
def
strengthL[A, B](a: A, f: F[B]): F[(A, B)]
Inject
a
to the left ofB
s inf
.Inject
a
to the left ofB
s inf
.- Definition Classes
- Functor
-
def
strengthR[A, B](f: F[A], b: B): F[(A, B)]
Inject
b
to the right ofA
s inf
.Inject
b
to the right ofA
s inf
.- Definition Classes
- Functor
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
traverse[A, G[_], B](value: G[A])(f: (A) ⇒ F[B])(implicit G: Traverse[G]): F[G[B]]
- Definition Classes
- Applicative
-
def
traverse1[A, G[_], B](value: G[A])(f: (A) ⇒ F[B])(implicit G: Traverse1[G]): F[G[B]]
- Definition Classes
- Apply
-
def
tuple2[A, B](fa: ⇒ F[A], fb: ⇒ F[B]): F[(A, B)]
- Definition Classes
- Apply
-
def
tuple3[A, B, C](fa: ⇒ F[A], fb: ⇒ F[B], fc: F[C]): F[(A, B, C)]
- Definition Classes
- Apply
-
def
tuple4[A, B, C, D](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D]): F[(A, B, C, D)]
- Definition Classes
- Apply
-
def
tuple5[A, B, C, D, E](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D], fe: ⇒ F[E]): F[(A, B, C, D, E)]
- Definition Classes
- Apply
-
def
void[A](fa: F[A]): F[Unit]
Empty
fa
of meaningful pure values, preserving its structure.Empty
fa
of meaningful pure values, preserving its structure.- Definition Classes
- Functor
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
Deprecated Value Members
-
def
map2[A, B, C](fa: ⇒ F[A], fb: ⇒ F[B])(f: (A, B) ⇒ C): F[C]
- Definition Classes
- Apply
- Annotations
- @deprecated
- Deprecated
(Since version 7) given
F: Apply[F]
useF.apply2(a,b)(f)
instead, or givenimplicitly[Apply[F]]
, use^(a,b)(f)
-
def
map3[A, B, C, D](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C])(f: (A, B, C) ⇒ D): F[D]
- Definition Classes
- Apply
- Annotations
- @deprecated
- Deprecated
(Since version 7) given
F: Apply[F]
useF.apply3(a,b,c)(f)
instead, or givenimplicitly[Apply[F]]
, use^^(a,b,c)(f)
-
def
map4[A, B, C, D, E](fa: ⇒ F[A], fb: ⇒ F[B], fc: ⇒ F[C], fd: ⇒ F[D])(f: (A, B, C, D) ⇒ E): F[E]
- Definition Classes
- Apply
- Annotations
- @deprecated
- Deprecated
(Since version 7) given
F: Apply[F]
useF.apply4(a,b,c,d)(f)
instead, or givenimplicitly[Apply[F]]
, use^^^(a,b,c,d)(f)
-
def
zip: Zip[F]
scalaz.Zip derived from
tuple2
.scalaz.Zip derived from
tuple2
.- Definition Classes
- Apply
- Annotations
- @deprecated
- Deprecated
(Since version 7.1.0) Apply#zip produces unlawful instances