compose

Function compose 

Source
pub fn compose<'a, Brand: Semigroupoid, B: 'a, C: 'a, D: 'a>(
    f: <Brand as Kind_fcf9d56b89a0b8b9>::Of<'a, C, D>,
    g: <Brand as Kind_fcf9d56b89a0b8b9>::Of<'a, B, C>,
) -> <Brand as Kind_fcf9d56b89a0b8b9>::Of<'a, B, D>
Expand description

Takes morphisms f and g and returns the morphism f . g (f composed with g).

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

§Type Signature

forall b c d. Semigroupoid a => (a c d, a b c) -> a b d

§Parameters

  • f: The second morphism to apply (from C to D).
  • g: The first morphism to apply (from B to C).

§Returns

The composed morphism (from B to D).

§Examples

use fp_library::classes::semigroupoid::compose;
use fp_library::brands::RcFnBrand;
use fp_library::classes::clonable_fn::ClonableFn;

let f = <RcFnBrand as ClonableFn>::new(|x: i32| x * 2);
let g = <RcFnBrand as ClonableFn>::new(|x: i32| x + 1);
let h = compose::<RcFnBrand, _, _, _>(f, g);
assert_eq!(h(5), 12); // (5 + 1) * 2