State Monad, categorically
May. 27th, 2016 06:15 amTake 1.
- unit is provided by the point,
- map is just a functoriality of cartesian product
- flatten is given by
Take 2. OTOH, a pointed object
What's the point then, why not take an arbitrary monoid M, and define
Take 3.
It is
- unit is given by currying
- map is obvious
- flatten is given by some obvious and canonical
So, the last one.
State[A,S] is just A×S, with a point s0:1→S.- unit is provided by the point,
A→A×S- map is just a functoriality of cartesian product
- flatten is given by
p1:S×S→S.Take 2. OTOH, a pointed object
S with a projection, p1:S×S→S, gives us a monoid.What's the point then, why not take an arbitrary monoid M, and define
State[A,M] using the monoidal properties of M?Take 3.
It is
(A×S)S, with the following operations:- unit is given by currying
id:A×S→A×S- map is obvious
- flatten is given by some obvious and canonical
(((A×S)S)×S)S → (A×S)S So, the last one.
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)

