Skip to main content

Module ref_applicative

Module ref_applicative 

Source
Expand description

By-ref applicative functors, combining RefPointed and RefSemiapplicative.

This is the by-ref counterpart of Applicative.

§Examples

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

// ref_pure clones a value into a Lazy context
let x = ref_pure::<LazyBrand<RcLazyConfig>, _>(&42);
assert_eq!(*x.evaluate(), 42);

// ref_apply applies a wrapped by-ref function
let f = RcLazy::pure(std::rc::Rc::new(|x: &i32| *x + 1) as std::rc::Rc<dyn Fn(&i32) -> i32>);
let result = ref_apply::<RcFnBrand, LazyBrand<RcLazyConfig>, _, _>(&f, &x);
assert_eq!(*result.evaluate(), 43);

Traits§

RefApplicative
A type class for by-ref applicative functors.