clm-kernel 0.0.23

Cubical Logic Model (CLM) sovereign execution engine, CPN-VM, and Cordis spatiotemporal substrate
Documentation
//! Pure function combinators for the Set category (INV-599): identity, compose, pipe.
//!
//! `compose(g, f)(x) == g(f(x))` (right to left) and `pipe(f, g)(x) == g(f(x))` (left to right).
//! Both are associative with `identity` as unit.

/// `id_A(x) = x`.
pub fn identity<T>(value: T) -> T {
    value
}

/// Right-to-left composition: `compose(g, f)(x) == g(f(x))`.
pub fn compose<A, B, C>(g: impl Fn(B) -> C, f: impl Fn(A) -> B) -> impl Fn(A) -> C {
    move |value| g(f(value))
}

/// Left-to-right composition: `pipe(f, g)(x) == g(f(x))`.
pub fn pipe<A, B, C>(f: impl Fn(A) -> B, g: impl Fn(B) -> C) -> impl Fn(A) -> C {
    move |value| g(f(value))
}