pub fn ref_apply<'a, FnBrand: 'a + CloneFn<Ref>, Brand: RefSemiapplicative, A: 'a, B: 'a>(
ff: &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, <FnBrand as CloneFn<Ref>>::Of<'a, A, B>>,
fa: &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>Expand description
Applies a wrapped by-ref function within a context to a value within a context.
Free function version that dispatches to the type class’ associated function.
§Type Signature
forall Brand A B. (CloneFn FnBrand, RefSemiapplicative Brand) => (&Brand (FnBrand A B), &Brand A) -> Brand B
§Type Parameters
'a: The lifetime of the values.FnBrand: The brand of the cloneable function wrapper.Brand: The brand of the context.A: The type of the input value.B: The type of the output value.
§Parameters
ff: The context containing the wrapped by-ref function(s).fa: The context containing the value(s).
§Returns
A new context containing the result(s) of applying the function(s) to the value(s).
§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);