Skip to main content

bind_flipped

Function bind_flipped 

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

Sequences a monadic computation (flipped argument order), inferring the brand from the container type.

The Brand type parameter is inferred from the concrete type of ma via the InferableBrand trait. For multi-brand types, the closure’s input type disambiguates which brand applies. For diagonal cases, use explicit::bind_flipped with a turbofish.

§Type Signature

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

§Type Parameters

  • 'a: The lifetime of the values.
  • FA: The container type (owned or borrowed). Brand is inferred from this.
  • A: The input element type.
  • B: The output element type.
  • Brand: The brand, inferred via InferableBrand from FA and the closure’s input type.

§Parameters

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

§Returns

The result of binding the function over the value.

§Examples

use fp_library::functions::*;

let result = bind_flipped(|x: i32| Some(x * 2), Some(5));
assert_eq!(result, Some(10));