Category#
- class discopy.abc.Category[source]#
Bases:
abc.ABC,GenericA category is a Python class with methods
dom, cod, id, then, together with an attributeobfor its objects.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])