pub fn bind<'a, Brand: Kind_cdc7cd43dac7585f, A: 'a, B: 'a, FA, Marker>(
ma: FA,
f: impl BindDispatch<'a, Brand, A, B, FA, Marker>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>Expand description
Sequences a monadic computation with a function that produces the next computation.
Dispatches to either Semimonad::bind or RefSemimonad::ref_bind
based on the closure’s argument type.
The Marker and FA type parameters are inferred automatically by the
compiler from the closure’s argument type and the container argument.
Callers write bind::<Brand, _, _, _, _>(...) and never need to specify
Marker or FA explicitly.
§Type Signature
forall Brand A B. Semimonad Brand => (Brand A, A -> Brand B) -> Brand B
§Type Parameters
'a: The lifetime of the values.Brand: The brand of the monad.A: The type of the value inside the monad.B: The type of the result.FA: The container type (owned or borrowed), inferred from the argument.Marker: Dispatch marker type, inferred automatically.
§Parameters
ma: The monadic value (owned for Val, borrowed for Ref).f: The function to apply to the value.
§Returns
The result of sequencing the computation.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = bind::<OptionBrand, _, _, _, _>(Some(5), |x: i32| Some(x * 2));
assert_eq!(result, Some(10));