Shift monad on order-preserving maps of natural numbers (source code)

= Shift monad on order-preserving maps of natural numbers
{title2=$\eta(n)=n+1,\quad\mu(n)=\max(n-1,0)$}

Let $M$ be the <monoid> of <order-preserving functions> $\mathbb N\to\mathbb N$, with $\mathbb N=\{0,1,\ldots\}$, regarded as a one-object <category>. The endofunctor $T$ fixes that object and sends $f$ to $Tf(0)=0$, $Tf(n+1)=f(n)+1$. The displayed maps give its <monad> unit and multiplication. The multiplication is not injective, so this is not an <idempotent monad>. Its only <algebra for a monad> is $\mu$, because $a\eta=1$ forces $a(n+1)=n$ and monotonicity forces $a(0)=0$. Algebra endomorphisms are exactly the functions fixing zero. The <Kleisli comparison functor> sends $f$ to the function which is zero at zero and equals $f(n)$ at $n+1$; its inverse sends $h$ to $n\mapsto h(n+1)$. Thus the comparison is an isomorphism of categories even though the monad is not idempotent.