monoidal.Functor

class discopy.monoidal.Functor(ob, ar, ob_factory=None, ar_factory=None)

Bases: discopy.cat.Functor

Implements a monoidal functor given its image on objects and arrows. One may define monoidal functors into custom categories by overriding the defaults ob_factory=Ty and ar_factory=Diagram.

>>> x, y, z, w = Ty('x'), Ty('y'), Ty('z'), Ty('w')
>>> f0, f1 = Box('f0', x, y, data=[0.1]), Box('f1', z, w, data=[1.1])
>>> F = Functor({x: z, y: w, z: x, w: y}, {f0: f1, f1: f0})
>>> assert F(f0) == f1 and F(f1) == f0
>>> assert F(F(f0)) == f0
>>> assert F(f0 @ f1) == f1 @ f0
>>> assert F(f0 >> f0[::-1]) == f1 >> f1[::-1]
>>> source, target = f0 >> f0[::-1], F(f0 >> f0[::-1])
>>> drawing.equation(
...     source, target, symbol='$\\mapsto$', figsize=(4, 2),
...     path='docs/_static/imgs/monoidal/functor-example.png')
../_images/functor-example.png