[Haskell-cafe] Re: Control.Monad.Cont fun

Magnus Carlsson magnus at carlssonia.org
Fri Jul 15 17:51:59 EDT 2005

Hi Thomas and Tomasz,

A late comment about a MonadFix instance for Cont/ContT:

Thomas Jäger wrote:
> Hello Tomasz,
> This stuff is very interesting! At first sight, your definition of
> getCC seems quite odd, but it can in fact be derived from its
> implementation in an untyped language.
> On 7/7/05, Tomasz Zielonka <tomasz.zielonka at gmail.com> wrote:


>>Besides sharing my happiness, I want to ask some questions:
>>- is it possible to define a MonadFix instance for Cont / ContT?
> It must be possible to define something that looks like a MonadFix
> instance, after all you can define generally recursive functions in
> languages like scheme and sml which "live in a ContT r IO monad", but
> this has all kinds of nasty consequences, iirc.
> Levent Erkök's thesis suggests (pp. 66) that there's no implementation
> of mfix that satisfies the purity law.
> http://www.cse.ogi.edu/PacSoft/projects/rmb/erkok-thesis.pdf

A while ago, I attempted to marry value recursion a la Levent Erkök with
the continuation-monad transformer.  It seems possible if the underlying
monad has value recursion and references.  Interestingly, all mfix
properties except left shrinking appear to be valid.

There are slides about this (including implementation) at


There is also a draft paper at


I should warn that the paper is still very unfinished.  If anyone is
interested in picking up the pieces together with me, please get in touch!


More information about the Haskell-Cafe mailing list