pub trait Category {
type Ob: Eq + Clone;
type Mor: Eq + Clone;
// Required methods
fn has_ob(&self, x: &Self::Ob) -> bool;
fn has_mor(&self, f: &Self::Mor) -> bool;
fn dom(&self, f: &Self::Mor) -> Self::Ob;
fn cod(&self, f: &Self::Mor) -> Self::Ob;
fn compose(&self, path: Path<Self::Ob, Self::Mor>) -> Self::Mor;
// Provided methods
fn compose2(&self, f: Self::Mor, g: Self::Mor) -> Self::Mor { ... }
fn id(&self, x: Self::Ob) -> Self::Mor { ... }
fn morphisms_are_equal(&self, f: Self::Mor, g: Self::Mor) -> bool { ... }
}
Expand description
A category.
We take the unbiased view of categories, meaning that composition is an operation on paths of arbitrary finite length. This has several advantages. First, it takes as primitive the natural data structure for morphisms in a free category, or more generally in a presentation of a category. It also enables more intelligent strategies for evaluating composites in specific categories. For instance, when composing (multiplying) a sequence of matrices, it can be very inefficient to just fold from the left or right, compared to multiplying in the optimal order.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn compose2(&self, f: Self::Mor, g: Self::Mor) -> Self::Mor
fn compose2(&self, f: Self::Mor, g: Self::Mor) -> Self::Mor
Composes a pair of morphisms with compatible (co)domains.
Sourcefn morphisms_are_equal(&self, f: Self::Mor, g: Self::Mor) -> bool
fn morphisms_are_equal(&self, f: Self::Mor, g: Self::Mor) -> bool
Are the two morphisms in the category equal?
The default implementation compares the morphisms with ==
. In some
categories, equality is defined by a weaker equivalence relation.