Skip to main content

second

Function second 

Source
pub fn second<'a, Brand: Strong, A: 'a, B: 'a, C: 'a>(
    pab: <Brand as Kind_266801a817966495>::Of<'a, A, B>,
) -> <Brand as Kind_266801a817966495>::Of<'a, (C, A), (C, B)>
Expand description

Lift a profunctor to operate on the second component of a pair.

Free function version that dispatches to the type class’ associated function.

§Type Signature

forall Brand A B C. Strong Brand => Brand A B -> Brand (C, A) (C, B)

§Type Parameters

  • 'a: The lifetime of the values.
  • Brand: The brand of the strong profunctor.
  • A: The input type of the profunctor.
  • B: The output type of the profunctor.
  • C: The type of the first component (threaded through unchanged).

§Parameters

  • pab: The profunctor instance to lift.

§Returns

A new profunctor that operates on pairs.

§Examples

use fp_library::{
	brands::*,
	classes::profunctor::*,
	functions::*,
};

let f = |x: i32| x + 1;
let g = second::<RcFnBrand, _, _, i32>(std::rc::Rc::new(f) as std::rc::Rc<dyn Fn(i32) -> i32>);
assert_eq!(g((20, 10)), (20, 11));