Category#
- class discopy.abc.Category[source]#
Bases:
abc.ABC,GenericA category is a class with two class variables
ob, ar, two attributesdom, codand two methodsid, then.This base class also implements syntactic sugar
>>and<<for forward and backward composition with the methodthen.Example
>>> class List(list, Category): ... ob, dom, cod = type(None), None, None ... def then(self, other): ... return self + other >>> assert List([1, 2]) >> List([3]) == List([1, 2, 3]) >>> assert List([3]) << List([1, 2]) == List([1, 2, 3])
- abstract classmethod id(dom)[source]#
Identity morphism on an object
dom: C0, to be instantiated.- Parameters:
dom (C0) – The domain of an identity is also its codomain.
- Return type:
C1
- abstract then(*others)[source]#
Sequential composition of n >= 1 morphisms, to be instantiated.
- Parameters:
other – The other morphism to compose sequentially.
others (C1) –
- Return type:
C1