pub fn bind<'a, Brand: Semimonad, B: 'a, A: 'a, F>(
ma: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
f: F,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, 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 m b a. Semimonad m => (m a, a -> m b) -> m b
§Type Parameters
Brand: The brand of the semimonad.B: The type of the result of the second computation.A: The type of the result of the first computation.F: The type of the function to apply.
§Parameters
ma: The first computation.f: The function to apply to the result of the first computation.
§Returns
The result of the second computation.
§Examples
use fp_library::{functions::*, brands::*};
let x = Some(5);
let y = bind::<OptionBrand, _, _, _>(x, |i| Some(i * 2));
assert_eq!(y, Some(10));