pub fn bind<'a, ClonableFnBrand: 'a + ClonableFn, Brand: Semimonad, A: 'a + Clone, B: Clone>(
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 type class’ associated function.
§Type Signature
forall a b. Semimonad 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));