[Haskell-cafe] Can every monad can be implemented with Cont? (was: New slogan for haskell.org)

Dan Doel dan.doel at gmail.com
Sat Oct 13 13:28:19 EDT 2007


On Saturday 13 October 2007, Albert Y. C. Lai wrote:
> jeff p wrote:
> > I think this is referring to Andrzej Filinski's paper "Representing
> > Layered Monads" in which it shown that stacks of monads can be
> > implemented directly (no layering) by using call/cc and mutable state.
>
> I have been unable to see how to bring its crucial "reify" and "reflect"
> to Haskell. In particular reflect:
>
> reflect :: m a -> a
>
> It looks very magical.

Here: http://cs.ioc.ee/mpc-amast06/msfp/filinski-slides.pdf

are some slides Filinski made about doing monadic reflection in Haskell (there 
might be a corresponding paper, but a cursory googling didn't find it).

The thing is, 'reflect' in Haskell doesn't have type 'm a -> a' It has type 
something like:

  m a -> ContState a

However, in the languages he usually works with, everything is already 
implicitly in a ContState monad, in that they have mutable references and 
native continuations. Hence the type 'm a -> a' there.

At least, I think that's the explanation.

-- Dan


More information about the Haskell-Cafe mailing list