Skip to main content

ref_join

Function ref_join 

Source
pub fn ref_join<'a, Brand: RefSemimonad, A: 'a>(
    mma: &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
where <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>: Clone,
Expand description

Like ref_bind, but with the arguments flipped. Collapses two nested layers of a by-ref semimonad into one.

Equivalent to ref_bind(mma, |ma| ma.clone()).

§Type Signature

forall Brand A. RefSemimonad Brand => &Brand (Brand A) -> Brand A

§Type Parameters

  • 'a: The lifetime of the computation.
  • Brand: The brand of the semimonad.
  • A: The type of the value inside the nested semimonad.

§Parameters

  • mma: The doubly-wrapped semimonadic value.

§Returns

The singly-wrapped semimonadic value.

§Examples

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

let inner = RcLazy::pure(5);
let outer = RcLazy::new({
	let inner = inner.clone();
	move || inner.clone()
});
let result = join::<LazyBrand<RcLazyConfig>, _, _>(&outer);
assert_eq!(*result.evaluate(), 5);