Trait higher::Bind

source ·
pub trait Bind<'a, A> {
    type Target<T>;

    fn bind<B, F>(self, f: F) -> Self::Target<B>
    where
        F: Fn(A) -> Self::Target<B> + 'a
; }
Expand description

Bind lets you chain computations together.

It takes a function Fn(A) -> M<B> and applies it to the A inside M<A>. You can think of this as a callback function for when the value of A is ready to be processed, returning the next computation in the sequence.

This is the primary component of the dreaded Monad trait, but to be a Monad a type must also implement Applicative, which in turn requires implementations for Functor, Pure and Apply.

Required Associated Types§

Required Methods§

Implementations on Foreign Types§

Implementors§