use crate::two_category::TwoCategory;
pub trait FFunctor<C1: TwoCategory, C2: TwoCategory> {
fn map_morphism<A: 'static, B: 'static>(f: C1::Morphism<A, B>) -> C2::Morphism<A, B>;
fn map_two_morphism(alpha: C1::TwoMorphism) -> C2::TwoMorphism;
}
pub struct IdentityFFunctor<C: TwoCategory>(core::marker::PhantomData<C>);
impl<C: TwoCategory> FFunctor<C, C> for IdentityFFunctor<C> {
fn map_morphism<A: 'static, B: 'static>(f: C::Morphism<A, B>) -> C::Morphism<A, B> {
f
}
fn map_two_morphism(alpha: C::TwoMorphism) -> C::TwoMorphism {
alpha
}
}
pub trait FMonad<C: TwoCategory>: FFunctor<C, C> {
fn unit<A: 'static>() -> C::TwoMorphism;
fn multiply<A: 'static>() -> C::TwoMorphism;
}
#[cfg(test)]
mod tests {
use super::*;
#[cfg(any(feature = "std", feature = "alloc"))]
use crate::two_category::Cat;
#[test]
fn identity_ffunctor_preserves_morphism() {
struct Marker;
impl TwoCategory for Marker {
type Morphism<A, B> = ();
type TwoMorphism = ();
fn id1<A: 'static>() -> Self::Morphism<A, A> {}
fn compose1<A: 'static, B: 'static, C: 'static>(
_: Self::Morphism<A, B>,
_: Self::Morphism<B, C>,
) -> Self::Morphism<A, C> {
}
fn id2() -> Self::TwoMorphism {}
fn compose2_vertical(_: Self::TwoMorphism, _: Self::TwoMorphism) -> Self::TwoMorphism {}
}
let _unit: () = IdentityFFunctor::<Marker>::map_morphism::<(), ()>(());
}
#[test]
fn id_ffunctor_preserves_two_morphism() {
struct Marker;
impl TwoCategory for Marker {
type Morphism<A, B> = ();
type TwoMorphism = ();
fn id1<A: 'static>() -> Self::Morphism<A, A> {}
fn compose1<A: 'static, B: 'static, C: 'static>(
_: Self::Morphism<A, B>,
_: Self::Morphism<B, C>,
) -> Self::Morphism<A, C> {
}
fn id2() -> Self::TwoMorphism {}
fn compose2_vertical(_: Self::TwoMorphism, _: Self::TwoMorphism) -> Self::TwoMorphism {}
}
let _unit: () = IdentityFFunctor::<Marker>::map_two_morphism(());
}
}