PS

Writer monad

Monoid lifting

Monoidal functors send monoids to monoids:

Monoidal functor:

  •  (F, \phi, u) : (\mathcal{C}, \otimes, I) \to (\mathcal{C'}, \otimes', I')

について、functor:

を定義できる。

Monads from monoids

特に、 F のcodomainがmonoidal category of endofunctors:

  •  (\mathcal{C'}, \otimes', I') := (\mathcal{C} ^ \mathcal{C}, \circ, 1 _ \mathcal{C})

のとき

Writer monad

  1.  F(m) := (\unicode{x2013}) \times m
  2.  (\phi _ {a, b}) _ c : ( c \times b) \times a \cong c \times (a \times b)
  3.  u _ a : a \cong a \times \lbrace \ast \rbrace

とすると、monoidal functor:

  •  (F, \phi, u) : ( \mathcal{Hask}, \times, \lbrace \ast \rbrace) \to ( \mathcal{Hask} ^ \mathcal{Hask}, \circ, 1 _ \mathcal{Hask} )

になるので、あるmonoid:

  •  (m, \mathtt{mempty}, \mathtt{mappend})

が存在すれば

  •  F _ \ast (m, \mathtt{mempty}, \mathtt{mappend}) \in \mathcal{Mnd}(\mathcal{Hask})

具体的には

  1.  (\unicode{x2013}) \times m
  2.  a \mapsto (a, \mathtt{mempty})
  3.  ( (a, w'), w) \mapsto (a, \mathtt{mappend}(w, w') )

monadを成す。

参考文献

*1:category of monoid objects

*2:category of monads