A bicategory is like a 2-Category but with composition of 1-cells associative and unital only up to invertible 2-cells. has small categories as objects, profunctors as 1-cells, and natural transformations (families natural in both arguments) as 2-cells. Composition is the Coend ; associativity holds only up to iso (Fubini and associativity of ), and the identity 1-cell is the hom-functor , by the ninja co-Yoneda lemma — again only up to iso.
Sources: DaoFP §17.8 (“The Bicategory of Profunctors”, “Monads in a bicategory”, “Prearrows as monads in Prof”); 7 Sketches §4.3 (-profunctors compose strictly when is a preorder — the quantale shadow), §4.4.
Monads in a bicategory. In any bicategory the endo-1-cells on an object form a monoidal category (tensor = 1-cell composition, unit = identity 1-cell); a monad is a monoid there: 2-cells , with the usual laws. In this recovers ordinary monads; in a monad is an endo-profunctor with and , i.e. (by co-continuity) elements of and — in Haskell a pre-arrow:
class Profunctor p => PreArrow p where
(>>>) :: p a x -> p x b -> p a b
arr :: (a -> b) -> p a bAn Arrow is a pre-arrow that is also a Tambara Module.
Docs: FinRelations
using Catlab, Catlab.CategoricalAlgebra.FinRelations
# Bool-profunctors between finite discrete categories are relations; composition is strict there
R = FinRelation((x, y) -> x < y, 3, 3); S = FinRelation((x, y) -> x == y + 1, 3, 3)
RS = compose(R, S) # relational composition = the coend over Bool
[RS(x, y) for x in 1:3, y in 1:3] # Bool matrix of the compositeimport Mathlib
open CategoryTheory
#check @CategoryTheory.Bicategory -- associators and unitors as invertible 2-cells
#check @CategoryTheory.Bicategory.Monad -- monads in a bicategoryclass Profunctor p => PreArrow p where
(>>>) :: p a x -> p x b -> p a b
arr :: (a -> b) -> p a b
instance PreArrow (->) where
f >>> g = g . f
arr = id