[Haskell-cafe] Re: MonadPrompt + Gtk2Hs = ?

Felipe Lessa felipe.lessa at gmail.com
Tue Jan 15 04:55:07 EST 2008


On Jan 14, 2008 8:27 PM, apfelmus <apfelmus at quantentunnel.de> wrote:
> The type of  contPromptM  is even more general than that:
>
>    casePromptOf' :: (r -> f b)
>                  -> (forall a,b. p a -> (a -> f b) -> f b)
>                  -> Prompt p r -> f b
>    casePromptOf' done cont (PromptDone r) = done r
>    casePromptOf' done cont (Prompt p c  ) = cont p (casePromptOf' done cont . c)

(I guess the forall b inside 'cont' is a typo?)

Actually, it can be as general as

casePromptOf :: (r -> b)
             -> (forall a. p a -> (a -> b) -> b)
             -> Prompt p r -> b
casePromptOf done cont (PromptDone r) = done r
casePromptOf done cont (Prompt p c  ) = cont p (casePromptOf done cont . c)

=)

And, just for the record,

runPromptAgain :: Monad m => (forall a. p a -> m a) -> Prompt p r -> m r
runPromptAgain f = casePromptOf return ((>>=) . f)


> The link to  ContT m a = (forall b . (a -> m b) -> m b)  is apparent in
> the case of  casePromptOf'  and is no surprise: you can omit  p a  and
> Prompt p r  entirely and implement them directly as continuations
> (thereby loosing the ability to use it with different m, which would
> defeat the whole point here.) See also
>
>    Implementing the State Monad.
>    http://article.gmane.org/gmane.comp.lang.haskell.cafe/31486
>
> for the details.

I've read that e-mail when it was sent but didn't understand it fully.
I guess now I'm in a better condition, but I still have a lot to learn
about these little warm, fuzzy things. Actually, the more I see, the
less I understand why some people are afraid of them... it must really
be the name 'monad'.

Thanks for all the help guys! Next I'll try to reproduce the freezes I
was getting with my first forkIO approach.

Cheers,

-- 
Felipe.


More information about the Haskell-Cafe mailing list