deep_causality_haft/algebra/
promonad.rs

1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) "2025" . The DeepCausality Authors and Contributors. All Rights Reserved.
4 */
5
6use crate::HKT3Unbound;
7
8/// The `Promonad` trait models the "fusion" or "interaction" of two contexts to produce a third.
9///
10/// # Category Theory
11/// This is related to **Monoidal Functors** and **Day Convolution**. It defines a mapping from the
12/// tensor product of two functors to a third functor:
13/// $$ F(A) \otimes G(B) \to H(A \otimes B) $$
14///
15/// In our Arity-3 definition $P<A, B, C>$, it acts as a "Pre-Arrow" or a specialized profunctor
16/// mapping $(A, B) \to C$.
17///
18/// # Use Cases
19/// *   **Tensor Contraction**: Merging a Vector $u$ and a Dual Vector $v^*$ to produce a Scalar.
20/// *   **Quantum Entanglement**: Combining Qubit A and Qubit B into an Entangled Pair C.
21/// *   **Force Calculation**: Combining Current $J$ and Magnetic Field $B$ to produce Force $F$.
22pub trait Promonad<P: HKT3Unbound> {
23    /// Merges two contexts into a third.
24    ///
25    /// # Arguments
26    /// * `pa`: The first context (Input A).
27    /// * `pb`: The second context (Input B).
28    /// * `f`: A function to combine the inner values $A$ and $B$ into $C$.
29    fn merge<A, B, C, F>(
30        pa: P::Type<A, A, A>, // Simplified signature for demonstration
31        pb: P::Type<B, B, B>,
32        f: F,
33    ) -> P::Type<C, C, C>
34    where
35        F: FnMut(A, B) -> C;
36
37    /// Fusion: Directly combines two raw inputs into the interaction context.
38    fn fuse<A, B, C>(input_a: A, input_b: B) -> P::Type<A, B, C>;
39}