<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi everyone,<div><br></div><div>I am experimenting with various implementation styles for classical FRP. My current thoughts are on a continuation-style push implementation, which can be summarized as follows.</div><div><br></div><div><div><font class="Apple-style-span" face="Courier">&gt; newtype EventT m r a &nbsp; &nbsp;= E { runE :: (a -&gt; m r) -&gt; m r -&gt; m r }</font></div><div><font class="Apple-style-span" face="Courier">&gt; newtype ReactiveT m r a = R { runR :: (m a -&gt; m r) -&gt; m r }</font></div></div><div><div><font class="Apple-style-span" face="Courier">&gt; type Event &nbsp; &nbsp;= EventT IO ()</font></div><div><font class="Apple-style-span" face="Courier">&gt;&nbsp;type Reactive = ReactiveT IO ()</font></div></div><div><br></div><div>The idea is that events allow subscription of handlers, which are automatically unsubscribed after the continuation has finished, while reactives allow observation of a shared state until the continuation has finished.</div><div><br></div><div>I managed to write the following Applicative instance</div><div><br></div><div><font class="Apple-style-span" face="Courier">&gt; instance Applicative (ReactiveT m r) where</font></div><div><div><font class="Apple-style-span" face="Courier">&gt;&nbsp;&nbsp; &nbsp; pure a &nbsp; &nbsp; &nbsp;= R $ \k -&gt; k (pure a)</font></div><div><font class="Apple-style-span" face="Courier">&gt;&nbsp;&nbsp; &nbsp; R f &lt;*&gt; R a = R $ \k -&gt; f (\f' -&gt; a (\a' -&gt; k $ f' &lt;*&gt; a'))</font></div></div><div><br></div><div>But I am stuck on finding a suitable Monad instance. I notice the similarity between my types and the ContT monad and have a feeling this similarity could be used to clean up my instance code, but am not sure how to proceed. Does anyone have an idea, or a pointer to suitable literature.</div><div><br></div><div>Best regards,</div><div>Hans</div></body></html>