On Sun, 04 Jun 2000, Marcin 'Qrczak' Kowalczyk wrote: 
> And "<-"-bound variables would be visible everywhere too?

That's right.

> I'm curious how the generic translation into mfix could look like if
> everything is visible everywhere, e.g.:
>     do
>         a <- f1 b
>         b <- f2 a
>         return (a,b)

Basically, this looks like:

     mfix (\~(a, b, v). do a <- f1 b
                           b <- f2 a
                           v <- return (a, b)
                           return (a, b, v))
            >>= \(a, b, v). return v

where mfix :: (a -> m a) -> m a  (m is the underlying monad), satisfying
certain axioms. It turns out that there's no generic mfix that'll work for any
monad, but many monads do possess an appropriate mfix. The idea is that the
new translation for do-notation will hide this recursive computation from the
user.

As Amr indicated, continuation monad (as far as we know) doesn't have an mfix:
it's properties are not compatible with the axioms we want.

Some speculation on the polymorphic let-bindings: In fact, we can deal with
polymorphic let-bindings within the do notation, but the translation gets a lot
more complicated, and we wanted to keep things as straightforward as possible.
The restriction that we want to impose is not essential, but it simplifies
things a lot. Furthermore, if a feature is almost never used why make the
semantics complicated just to support it? 

-Levent.

Reply via email to