Expand description
Contexts supporting by-reference monadic sequencing via bind.
Like Semimonad::bind, but the closure
receives &A instead of A. This enables memoized types like
Lazy to participate in monadic sequencing without
giving up their cached value.
§Examples
use fp_library::{
brands::*,
classes::*,
types::*,
};
let lazy = RcLazy::pure(5);
let result = LazyBrand::<RcLazyConfig>::ref_bind(&lazy, |x: &i32| {
Lazy::<_, RcLazyConfig>::new({
let v = *x;
move || v * 2
})
});
assert_eq!(*result.evaluate(), 10);Traits§
- RefSemimonad
- A type class for contexts supporting by-reference monadic sequencing.