I'm with @Rhymoid on this one, I believe all Monads have two (!!) transformers. My construction is a bit different, and far less complete. I'd like to be able to take this sketch into a proof, but I think I'm either missing the skills/intuition and/or it may be quite involved.
Due to Kleisli, every monad (m
) can be decomposed into two functors F_k
and G_k
such that F_k
is left adjoint to G_k
and that m
is isomorphic to G_k * F_k
(here *
is functor composition). Also, because of the adjunction, F_k * G_k
forms a comonad.
I claim that t_mk
defined such that t_mk n = G_k * n * F_k
is a monad transformer. Clearly, t_mk Id = G_k * Id * F_k = G_k * F_k = m
. Defining return
for this functor is not difficult since F_k
is a "pointed" functor, and defining join
should be possible since extract
from the comonad F_k * G_k
can be used to reduce values of type (t_mk n * t_mk n) a = (G_k * n * F_k * G_k * n * F_k) a
to values of type G_k * n * n * F_k
, which is then further reduces via join
from n
.
We do have to be a bit careful since F_k
and G_k
are not endofunctors on Hask. So, they are not instances of the standard Functor
typeclass, and also are not directly composable with n
as shown above. Instead we have to "project" n
into the Kleisli category before composition, but I believe return
from m
provides that "projection".
I believe you can also do this with the Eilenberg-Moore monad decomposition, giving m = G_em * F_em
, tm_em n = G_em * n * F_em
, and similar constructions for lift
, return
, and join
with a similar dependency on extract
from the comonad F_em * G_em
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…