pub fn map_output<'a, Brand: Profunctor, A: 'a, B: 'a, C: 'a>(
bc: impl Fn(B) -> C + 'a,
pab: <Brand as Kind_266801a817966495>::Of<'a, A, B>,
) -> <Brand as Kind_266801a817966495>::Of<'a, A, C>Expand description
Maps covariantly over the second argument.
Corresponds to rmap in both Haskell and PureScript.
Free function version that dispatches to the type class’ associated function.
§Type Signature
forall Brand A B C. Profunctor Brand => (B -> C, Brand A B) -> Brand A C
§Type Parameters
'a: The lifetime of the values.Brand: The brand of the profunctor.A: The input type.B: The original output type.C: The new output type.
§Parameters
bc: The covariant function to apply to the output.pab: The profunctor instance.
§Returns
A new profunctor instance with transformed output type.
§Examples
use fp_library::{
brands::*,
classes::profunctor::*,
functions::*,
};
let f = |x: i32| x + 1;
let g = map_output::<RcFnBrand, _, _, _>(
|x: i32| x * 2,
std::rc::Rc::new(f) as std::rc::Rc<dyn Fn(i32) -> i32>,
);
assert_eq!(g(10), 22); // (10 + 1) * 2 = 22