pub fn map<'a, ClonableFnBrand: 'a + ClonableFn, Brand: Functor + ?Sized, A: 'a, B: 'a>(
f: ApplyFn<'a, ClonableFnBrand, A, B>,
) -> ApplyFn<'a, ClonableFnBrand, Apply0L1T<Brand, A>, Apply0L1T<Brand, B>>
Expand description
Maps a function over the values in the functor context.
Free function version that dispatches to the typeclass’ associated function.
§Type Signature
forall f a b. Functor f => (a -> b) -> f a -> f b
§Parameters
f
: A function to apply to the values within the functor context.fa
: A functor containing values of typeA
.
§Returns
A functor containing values of type B
.
§Examples
use fp_library::{brands::{OptionBrand, RcFnBrand}, functions::map};
use std::rc::Rc;
assert_eq!(map::<RcFnBrand, OptionBrand, _, _>(Rc::new(|x: i32| x * 2))(Some(5)), Some(10));