pub fn bind<'a, ClonableFnBrand: 'a + ClonableFn, Brand: Bind, A: 'a + Clone, B>(
ma: Apply0L1T<Brand, A>,
) -> ApplyFn<'a, ClonableFnBrand, ApplyFn<'a, ClonableFnBrand, A, Apply0L1T<Brand, B>>, Apply0L1T<Brand, B>>
Expand description
Sequences two computations, allowing the second to depend on the value computed by the first.
Free function version that dispatches to the typeclass’ associated function.
§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.
§Examples
use fp_library::{brands::{OptionBrand, RcFnBrand}, functions::{bind, pure}};
use std::rc::Rc;
assert_eq!(bind::<RcFnBrand, OptionBrand, _, _>(Some(5))(Rc::new(|x| Some(x * 2))), Some(10));