pub fn map<'a, Brand: Functor, A: 'a, B: 'a, F>(
f: F,
fa: Apply1L1T<'a, Brand, A>,
) -> Apply1L1T<'a, Brand, B>where
F: Fn(A) -> B + 'a,Expand description
Maps a function over the values in the functor context.
Free function version that dispatches to the type class’ associated function.
§Type Signature
forall a b. Functor f => (a -> b, f a) -> f b
§Parameters
f: The function to apply to the value(s) inside the functor.fa: The functor instance containing the value(s).
§Returns
A new functor instance containing the result(s) of applying the function.
§Examples
use fp_library::classes::functor::map;
use fp_library::brands::OptionBrand;
let x = Some(5);
let y = map::<OptionBrand, _, _, _>(|i| i * 2, x);
assert_eq!(y, Some(10));