In Haskell, Given a monad m
, there is mfix :: (a -> m a) -> m a
that computes the fixed-point of a monadic computation.
Dually, given a comonad w
, there is cofix :: w (w a -> a) -> a
that computes the fixed-point of a comonadic computations.
Now suppose that I have a program that uses both a monad m
and a comonad w
that are related by a distributivity law distr :: w (m a) -> m (w a)
of the comonad over the monad. Is it possible to combine mfix
and cofix
into a function of type w (w a -> m a) -> m a
that would compute the fixpoint of monadic and comonadic computations?