semigroupoid_compose

Function semigroupoid_compose 

Source
pub fn semigroupoid_compose<'a, ClonableFnBrand: 'a + ClonableFn, Brand: Semigroupoid, B, C, D>(
    f: Apply1L2T<'a, Brand, C, D>,
) -> ApplyFn<'a, ClonableFnBrand, Apply1L2T<'a, Brand, B, C>, Apply1L2T<'a, Brand, 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: A morphism of type a c d.
  • g: A morphism of type a b c.

§Returns

The morphism f composed with g of type a b d.

§Examples

use fp_library::{brands::RcFnBrand, functions::semigroupoid_compose};
use std::rc::Rc;

let add_one = Rc::new(|x: i32| x + 1);
let times_two = Rc::new(|x: i32| x * 2);
let times_two_add_one = semigroupoid_compose::<RcFnBrand, RcFnBrand, _, _, _>(add_one)(times_two);

// 3 * 2 + 1 = 7
assert_eq!(times_two_add_one(3), 7);