pub fn arrow<'a, Brand, A, B: 'a>(
f: impl 'a + Fn(A) -> B,
) -> <Brand as Kind_266801a817966495>::Of<'a, A, B>where
Brand: Category + Profunctor,Expand description
Lifts a pure function into a profunctor context.
Given a type that is both a Category (providing identity) and a
Profunctor (providing map_output), this function lifts a pure function
A -> B into the profunctor as map_output(f, identity()).
§Type Signature
forall Brand A B. (Category Brand, Profunctor Brand) => (A -> B) -> Brand A B
§Type Parameters
'a: The lifetime of the function and its captured data.Brand: The brand of the profunctor.A: The input type.B: The output type.
§Parameters
f: The closure to lift.
§Returns
The lifted profunctor value.
§Examples
use fp_library::{
brands::*,
functions::*,
};
let f = arrow::<RcFnBrand, _, _>(|x: i32| x * 2);
assert_eq!(f(5), 10);