Skip to main content

Module ref_semiapplicative

Module ref_semiapplicative 

Source
Expand description

Applying wrapped by-ref functions within contexts with ref_apply.

Like Semiapplicative::apply, but the wrapped functions receive &A instead of owned values. Uses CloneFn<Ref> for the function wrappers.

§Examples

use fp_library::{
	brands::*,
	classes::*,
	functions::*,
	types::*,
};

let f = RcLazy::pure(std::rc::Rc::new(|x: &i32| *x * 2) as std::rc::Rc<dyn Fn(&i32) -> i32>);
let x = RcLazy::pure(5);
let result = ref_apply::<RcFnBrand, LazyBrand<RcLazyConfig>, _, _>(&f, &x);
assert_eq!(*result.evaluate(), 10);

Traits§

RefSemiapplicative
A type class for applying wrapped by-ref functions within contexts.

Functions§

ref_apply
Applies a wrapped by-ref function within a context to a value within a context.