use super::entity::Entity;
use super::relationship::Relationship;
pub trait Category {
type Object: Entity;
type Morphism: Relationship<Object = Self::Object>;
fn identity(obj: &Self::Object) -> Self::Morphism;
fn compose(f: &Self::Morphism, g: &Self::Morphism) -> Option<Self::Morphism>;
fn morphisms() -> Vec<Self::Morphism>;
fn morphisms_from(obj: &Self::Object) -> Vec<Self::Morphism> {
Self::morphisms()
.into_iter()
.filter(|m| &m.source() == obj)
.collect()
}
fn morphisms_to(obj: &Self::Object) -> Vec<Self::Morphism> {
Self::morphisms()
.into_iter()
.filter(|m| &m.target() == obj)
.collect()
}
}