pub struct Coend<P, A>where
P: HKT2,{
pub value: <P as HKT2>::P<A, A>,
}Expand description
A Coend for profunctor P: represents ∫^A P(A, A), i.e., exists A. P(A, A).
In category theory, the coend of a profunctor P: C^op × C -> Set is the
universal cowedge — a value P(A, A) for SOME (existentially hidden) type A.
Since Rust lacks first-class existential types, the type parameter A is
exposed (following the same pragmatic approach as Lan<G, H, A, B> in
karpal-free). Users should treat A as opaque when consuming coend values.
§Construction
use karpal_core::coend::Coend;
use karpal_core::hkt::TupleF;
// A coend value: exists some A such that we have (A, A)
let c: Coend<TupleF, i32> = Coend::new((42, 42));
assert_eq!(c.value, (42, 42));Fields§
§value: <P as HKT2>::P<A, A>The diagonal value P(A, A) for the existentially quantified A.
Implementations§
Source§impl<P, A> Coend<P, A>where
P: HKT2,
impl<P, A> Coend<P, A>where
P: HKT2,
Sourcepub fn new(value: <P as HKT2>::P<A, A>) -> Coend<P, A>
pub fn new(value: <P as HKT2>::P<A, A>) -> Coend<P, A>
Construct a coend value from a diagonal element.
Sourcepub fn elim<R>(self, f: impl FnOnce(<P as HKT2>::P<A, A>) -> R) -> R
pub fn elim<R>(self, f: impl FnOnce(<P as HKT2>::P<A, A>) -> R) -> R
Eliminate the coend by applying a function to the diagonal value.
Given a function P(A, A) -> R, extract a result. This is the
concrete elimination form — in category theory, the eliminator
would be a dinatural transformation, but here the type parameter
A is exposed rather than existentially hidden.