[Haskell-cafe] My try for a CoroutineT monad tranformer

Joachim Breitner mail at joachim-breitner.de
Fri Apr 25 15:23:20 EDT 2008


Hi,

Am Freitag, den 25.04.2008, 11:49 -0700 schrieb Dan Weston:
> I guess like minds think alike! See the very recent e-mail thread 
> started by Ryan Ingram:
> http://thread.gmane.org/gmane.comp.lang.haskell.cafe/39155/focus=39159
> 
> Take a look at the code referenced in Luke Palmer's reply:
> http://luqui.org/git/?p=luqui-misc.git;a=blob;f=work/code/haskell/frp/Fregl/Suspend.hs
> 
> A snippet follows:
> 
>  > class (Monad m) => MonadSuspend v m | m -> v where
>  >   attempt :: m a -> m (Either a (v -> m a))
>  >   suspend :: m v
>  >
>  > newtype SuspendT v m a
>  >   = SuspendT { runSuspendT :: m (Either a (v -> SuspendT v m a)) }
> 
> Your (Coroutine m a) appears to be isomorphic to (SuspendT () m a) [so 
> Coroutine m () = SuspendT () m ()]
> 
> Your runCoroutineT appears to be isomorphic to a specialization of 
> runSuspendT:
> 
> runSuspendT' :: SuspendT () m () -> m (Either () (() -> SuspendT () m ()))
> 
> Here the () -> a ~ a and Either () a ~ Maybe a

You are quite right, it really is the same thing. The implementation
behind runCoroutineT is not just a specialization, but the exact same
thing (with Left and Right switched). I just put the specialization
there because I had no need for a return value in my use case.

And interesting how Ryan and me had the same thoughts on the same day.
Maybe the April 24th should be considered Suspend You Monadic Action
Day.

Greetings,
Joachim

-- 
Joachim Breitner
  e-Mail: mail at joachim-breitner.de
  Homepage: http://www.joachim-breitner.de
  ICQ#: 74513189
  Jabber-ID: nomeata at joachim-breitner.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080425/86613df8/attachment.bin


More information about the Haskell-Cafe mailing list