Skip to main content

bind_flipped

Function bind_flipped 

Source
pub fn bind_flipped<'a, Brand: Kind_cdc7cd43dac7585f, A: 'a, B: 'a, FA, Marker>(
    f: impl BindDispatch<'a, Brand, A, B, FA, Marker>,
    ma: FA,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
Expand description

Binds a monadic value to a function (flipped argument order).

Dispatches to Semimonad::bind or RefSemimonad::ref_bind based on whether the closure takes A or &A. Delegates to BindDispatch internally.

§Type Signature

forall Brand A B. Semimonad Brand => (A -> Brand B, Brand A) -> Brand B

§Type Parameters

  • 'a: The lifetime of the values.
  • Brand: The higher-kinded type brand.
  • A: The input element type.
  • B: The output element type.
  • FA: The container type (owned or borrowed), inferred from the argument.
  • Marker: Marker type, inferred from the closure.

§Parameters

  • f: The function to apply to each element.
  • ma: The monadic value to bind over (owned for Val, borrowed for Ref).

§Returns

The result of binding the function over the value.

§Examples

use fp_library::{
	brands::*,
	functions::explicit::*,
};

// By-value
let result = bind_flipped::<OptionBrand, _, _, _, _>(|x: i32| Some(x * 2), Some(5));
assert_eq!(result, Some(10));