pub trait Promonad<P: HKT3Unbound> {
// Required methods
fn merge<A, B, C, F>(
pa: P::Type<A, A, A>,
pb: P::Type<B, B, B>,
f: F,
) -> P::Type<C, C, C>
where A: Satisfies<P::Constraint>,
B: Satisfies<P::Constraint>,
C: Satisfies<P::Constraint>,
F: FnMut(A, B) -> C;
fn fuse<A, B, C>(input_a: A, input_b: B) -> P::Type<A, B, C>
where A: Satisfies<P::Constraint>,
B: Satisfies<P::Constraint>,
C: Satisfies<P::Constraint>;
}Expand description
The Promonad trait models the “fusion” or “interaction” of two contexts to produce a third.
§Category Theory
This is related to Monoidal Functors and Day Convolution. It defines a mapping from the tensor product of two functors to a third functor: $$ F(A) \otimes G(B) \to H(A \otimes B) $$
In our Arity-3 definition $P<A, B, C>$, it acts as a “Pre-Arrow” or a specialized profunctor mapping $(A, B) \to C$.
§Use Cases
- Tensor Contraction: Merging a Vector $u$ and a Dual Vector $v^*$ to produce a Scalar.
- Quantum Entanglement: Combining Qubit A and Qubit B into an Entangled Pair C.
- Force Calculation: Combining Current $J$ and Magnetic Field $B$ to produce Force $F$.
Required Methods§
Sourcefn merge<A, B, C, F>(
pa: P::Type<A, A, A>,
pb: P::Type<B, B, B>,
f: F,
) -> P::Type<C, C, C>where
A: Satisfies<P::Constraint>,
B: Satisfies<P::Constraint>,
C: Satisfies<P::Constraint>,
F: FnMut(A, B) -> C,
fn merge<A, B, C, F>(
pa: P::Type<A, A, A>,
pb: P::Type<B, B, B>,
f: F,
) -> P::Type<C, C, C>where
A: Satisfies<P::Constraint>,
B: Satisfies<P::Constraint>,
C: Satisfies<P::Constraint>,
F: FnMut(A, B) -> C,
Merges two contexts into a third.
§Arguments
pa: The first context (Input A).pb: The second context (Input B).f: A function to combine the inner values $A$ and $B$ into $C$.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.