pub fn bind<'a, Brand: Bind, A: 'a + Clone, B>(
ma: Apply1<Brand, A>,
) -> ArcFn<'a, ArcFn<'a, A, Apply1<Brand, B>>, Apply1<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, functions::{bind, pure}};
use std::sync::Arc;
assert_eq!(bind::<OptionBrand, _, _>(Some(5))(Arc::new(|x| Some(x * 2))), Some(10));