[Haskell-cafe] Re: Can we come out of a monad?

Ertugrul Soeylemez es at ertes.de
Wed Aug 11 08:32:48 EDT 2010


"Edward Z. Yang" <ezyang at MIT.EDU> wrote:

> Excerpts from Ertugrul Soeylemez's message of Tue Aug 10 03:40:02 -0400 2010:
> > Then you can only run evalCont, if r = a, which makes that function
> > quite pointless:
> >
> >   evalCont :: Cont r r -> r
> >   evalCont = runCont id
>
> Ah, yes, that was what I was imagining.  I don't think the function is
> useless (though it is pointless ;-); it lets you transform
> continuation-style code into normal code.  Also, r is usually not
> fixed (unless you use mapCont or similar), so it might be more
> accurately described as Cont a a -> a.

My point was, I would just write 'runCont id'. ;)

The result type of the computation is fixed.  It cannot change between
(>>=).  Note that 'a' is the result of one subcomputation, i.e. the
result of one particular CPS-style function, while 'r' is the result of
the entire computation.  So runCont should give you an 'r', not an 'a'.
In this case, they just happen to be the same.  But of course this is
really a matter of taste. =)


Greets,
Ertugrul


-- 
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/




More information about the Haskell-Cafe mailing list