The term action first appeared in the context of
group actions which have the form ⊘:C×D→D where D is a group and C is a
set. We say that C is acting on D or that ⊘ is an action of C on D.
We can generalise this notion for any category D with a monoidal category C using a bifunctor ⊘:C⊗D→D and some coherence conditions.
Definition
Given two categories C and D, with C being monoidal (⊗,I,α,l,r) we say that C acts on D if we the following:
A bifunctor called the action ⊘:C×D→D
A natural isomorphism called the “actor” a:∀x,y∈∣C∣,z∈∣D∣.(x⊗y)⊘z⇔x⊘(y⊘z)
A natural transformation neutralising the monoidal unit e:I⊘x⇔x
There is a commutative pentagon relating (((x⊗y)⊗z)⊘w) and x⊘(y⊘(z⊘w)) given by α×idw;a;idx×a=a;a
There is a left unitor: a;l⊘id=e
There is a right unitor: a;id⊘e=r⊘id
public exportrecord Action {0 o1, o2 : Type} (c : Category o1) (d : Category o2) (mon : Monoidal c) where constructor MkAction action : Bifunctor c d d
Equipped with our action we define the actor diagram that ensures the relationship
between the monoidal structure of C and the bifunctor. It’s a little bit hard to follow what f1 and f2 are but they are each branch of the diagram in figure \ref{fig:actor-diag}
actor : let 0 f1 : (c × (c × d)) ->> d f1 = pair (idF c) action ⨾⨾ action 0 f2 : (c × (c × d)) ->> d f2 = assocR ⨾⨾ pair mon.mult (idF d) ⨾⨾ action in f1 =~= f2
And our unitor diagram ensuring the relationship between the action and the monoidal unit of C
This previous definition makes use of natural isomorphisms, but we can also define a notion of lax action
that makes use of natural transformations instead, ensuring the conversion only goes one way.
Definition
A lax action is an action using natural transformation instead of natural isomorphisms.
We give a matching idris definition. It is this definition of action that we are going to use for Containers.
record LaxAction {0 o1, o2 : Type} (c : Category o1) (d : Category o2) (mon : Monoidal c) where constructor MkLaxAction laction : Bifunctor c d d lactor : let 0 f1, f2 : (c × (c × d)) ->> d f1 = pair (idF c) laction ⨾⨾ laction f2 = assocR ⨾⨾ pair mon.mult (idF d) ⨾⨾ laction in f1 =>> f2 lunitor : idF d =>> Bifunctor.applyL {a = c} mon.i laction
From an action we can obtain a lax-action by only projecting the natural transformations out of the natural isomorphisms.
Proposition
From any action (⊘,m,u), we can derive a lax-action by projecting out one side of the natural isomorphisms m and u.
A monoidal category is a special case of an action where the acting category is the same as the category being acted upon.
We formalise this idea by introducing monoidal categories as a self-action and derive an action ⊘:D×D→D by simply reusing the monoidal product.
Proposition
From any monoidal category C emerges an action of C on itself.