pub trait Bind {
// Required method
fn bind<F, A, B>(ma: Apply<Self, (A,)>) -> impl Fn(F) -> Apply<Self, (B,)>
where Self: Kind<(A,)> + Kind<(B,)> + Sized,
Apply<Self, (A,)>: Clone,
F: Fn(A) -> Apply<Self, (B,)>;
}
Expand description
Sequences two computations, allowing the second to depend on the value computed by the first.
If x
has type m a
and f
has type a -> m b
, then bind(x)(f)
has type m b
,
representing the result of executing x
to get a value of type a
and then
passing it to f
to get a computation of type m b
.
Note that Bind
is a separate typeclass from Monad
. In this library’s
hierarchy, Monad
is a typeclass that extends both
Applicative
and Bind
.
Required Methods§
Sourcefn bind<F, A, B>(ma: Apply<Self, (A,)>) -> impl Fn(F) -> Apply<Self, (B,)>
fn bind<F, A, B>(ma: Apply<Self, (A,)>) -> impl Fn(F) -> Apply<Self, (B,)>
Sequences two computations, allowing the second to depend on the value computed by the first.
§Type Signature
forall m a b. Bind m => m a -> (a -> m b) -> m b
§Parameters
ma
: The first computation in the context.f
: A function that takes the result of the first computation and returns the second computation in the context.
§Returns
A computation that sequences the two operations.