I've been trying to code up the Eilenberg-Moore category for a monad in Haskell.
As I understand it, given a category $C$ and a monad $(T,\eta,\mu)$ on $C$ we build the Eilenberg-Moore category $C^T$ as the category whose objects are algebras on $a$, i.e. pairs consisting of an object $a$ of $C$ and a map $h:Ta\to a$ satisfying some properties, and whose morphisms are algebra homomorphisms.
The functor $G:C^T \to C$ is a forgetful functor that acts like
$$G(a,h:Ta \to a) = a$$
$$G(f:a\to b,\, g:(Ta\to a)\to(Tb\to b)) = f$$
The functor $F:C\to C^T$ acts on objects as
$$Fa = (Ta,\,\mu)$$
but I don't understand what it does to morphisms. I have
$$Ff = (Tf,\, \_ )$$
but I don't understand what goes in the _.
I need to create something of type $(T(Ta) \to Ta)\to (T(Tb)\to Tb)$ out of
$$\mu:T(Ta)\to Ta$$
$$\eta:a\to Ta$$
$$f:a\to b$$
$$T:(a\to b)\to (Ta\to Tb)$$
But I can't see how to do it. I suppose one option would be the function that takes every algebra $h$ to $\mu$, i.e.
$$Ff = (Tf, \lambda h.\mu)$$
but I'm not even convinced that's an algebra homomorphism. Am I missing something?

a -> m bas morphisms fromatob. In a sensea"codes up" the freemalgebra ona. When it comes to Eilenberg-Moore you can't take that route since you can't pair a type with a value in Haskell. What approach were you aiming for? – Tom Ellis Feb 26 at 22:05newtype Algebra t a = Algebra (t a -> a)andnewtype Morphism t a b = Morphism (a -> b)- so you don't actually need to pair a type with a value, it's implicit in the definition. So given an algebra $(a,h:Ta \to a)$ and a morphism $f:a\to b$ you can't actually return the algebra that the morphism maps to, but you can check that some morphism $f:a\to b$ is an algebra homomorphism between $(a,h:Ta\to a)$ and $(b,k:Tb\to b)$ by checking (modulo newtypes) that $k\circ Tf = f\circ h$. – Chris Taylor Feb 26 at 22:20