Bind

Trait Bind 

Source
pub trait Bind: Kind0L1T {
    // Required method
    fn bind<'a, ClonableFnBrand: 'a + ClonableFn, A: 'a + Clone, B>(
        ma: Apply0L1T<Self, A>,
    ) -> ApplyFn<'a, ClonableFnBrand, ApplyFn<'a, ClonableFnBrand, A, Apply0L1T<Self, B>>, Apply0L1T<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§

Source

fn bind<'a, ClonableFnBrand: 'a + ClonableFn, A: 'a + Clone, B>( ma: Apply0L1T<Self, A>, ) -> ApplyFn<'a, ClonableFnBrand, ApplyFn<'a, ClonableFnBrand, A, Apply0L1T<Self, B>>, Apply0L1T<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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Bind for OptionBrand

Source§

impl Bind for SoloBrand

Source§

impl Bind for VecBrand

Source§

impl<E> Bind for ResultWithErrBrand<E>
where for<'a> E: 'a + Clone,

Source§

impl<T> Bind for ResultWithOkBrand<T>
where for<'a> T: 'a + Clone,