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

Luke Palmer lrpalmer at gmail.com
Tue Aug 10 01:04:04 EDT 2010

On Mon, Aug 9, 2010 at 1:19 PM, John Lato <jwlato at gmail.com> wrote:
> I don't find purify2 particularly helpful because I almost never want
> to break out of any arbitrary monad; I want to be able to break out of
> a specific monad without knowing which monad it is, that is:
> purify3 :: Monad m => m a -> a
> purify3 = undefined  --the only possible definition...
> However, I just realized that something else is almost as good:
> evalCont :: Cont r a -> r
> evalCont k = runCont k id

Except, of course, you want the signature

  evalCont :: Cont r a -> a

Which is not possible.  But I am not sure where all this discussion is
coming from, Maybe and (r ->) cannot be broken out of.  Isn't that
example enough?


More information about the Haskell-Cafe mailing list