pub fn map<Brand, F, A, B>(
f: F,
) -> impl Fn(Apply<Brand, (A,)>) -> Apply<Brand, (B,)>
Expand description
Maps a function over the values in the functor context.
Free function version that dispatches to the typeclass method.
§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, functions::map};
assert_eq!(map::<OptionBrand, _, _, _>(|x: i32| x * 2)(Some(5)), Some(10));