<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-06-29 10:31 GMT+02:00 Corentin Dupont <span dir="ltr"><<a href="mailto:corentin.dupont@gmail.com" target="_blank">corentin.dupont@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div><div>I understand, my comment was just on the syntax.<br></div>Actually I have the same problem with "guard":<br><br></div>test x = do<br></div></div>   guard x<br></div><div>   XXXXXXXXX<br></div>   YYYYYYYYY<br>   ....<br><br></div><div>Unless I read all the monad body, there is no visual cue that XXX and YYY might not be run.<br></div><div>The control flow is not syntactically visible.<br></div><div>That's why I prefer using guards like that:<br><br></div>test x = do<br>   guard x >> do<br><div>      XXXXXXXXX<br></div>      YYYYYYYYY<br>      ....<br><br></div>Here the indentation shows that there is a control flow decision.<br></div>Is it possible to do the same thing with Transient?<br></div>Something like:<br><br><pre><span class="">main <span>=</span> keep <span>$</span> <span>do</span></span>
    async (<span>return</span> <span><span>"hello</span><span>"</span></span>) <span><|></span> async (<span>return</span> <span><span>"</span>world<span>"</span></span>) >>= \r -> do
       liftIO <span>$</span> <span>print</span> r<span></span></pre><br></div></blockquote><div>Yes, it is possible, just like in any other monad.  but the alternative expression must be in parenthesis if  you want both results to be printed. I do not remember which operator has more precedence <|> or >>=. I guess >>=</div><div><br></div><div><pre><span class="">main = keep $ do</span>
    (async (return "hello") <|> async (return "world")) >>= \r -> do
       liftIO $ print r</pre></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><br></div></div></div></div><div class=""><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 28, 2016 at 7:25 AM, Geraldus <span dir="ltr"><<a href="mailto:heraldhoi@gmail.com" target="_blank">heraldhoi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">This is because the whole computation is kept (via `keep`).  If you just run computation with `runTransient` you will see only “world” in output and then program ends, however since the computation is kept when second action finishes it prints “hello”. <div><br></div><div>`r <- async … <|> async …`</div><div>Here `r` is a continuation, everything below it will be re-computed when any of alternatives will return a result.  For example, you can add another choice:</div><div>`r <- async … <|> async … <|> waitEvents someEventAction`<br></div><div>In this case every time your `someEventAction` returns a value `r` takes it and the rest of code re-executed (or in other words when you have a new continuation the computation re-evaluated).</div><div><br></div><div>Hope this makes sense.</div></div><br><div class="gmail_quote"><div dir="ltr">вт, 28 июн. 2016 г. в 3:31, Corentin Dupont <<a href="mailto:corentin.dupont@gmail.com" target="_blank">corentin.dupont@gmail.com</a>>:<br></div><div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Wow, it is very impressive. I need to give it more time.<br></div>I have one question regarding this example:<br><pre>main <span>=</span> keep <span>$</span> <span>do</span>
    th <span><-</span> liftIO myThreadId                                   <span>-- thread 89</span>
    r <span><-</span> async (<span>do</span> threadDelay <span>1000000</span>; <span>return</span> <span><span>"</span>hello<span>"</span></span>)       <span>-- thread 90</span>
         <span><|></span> async (<span>return</span> <span><span>"</span>world<span>"</span></span>)                           <span>-- thread 91</span>
    th' <span><-</span> liftIO myThreadId                                  <span>-- thread 90 and 91</span>
    liftIO <span>$</span> <span>print</span> (th, th', r)                               <span>-- thread 90 and 91</span></pre>

<p>Output:</p>

<pre><code>(ThreadId 89,ThreadId 91,"world")
(ThreadId 89,ThreadId 90,"hello")
</code></pre><br><div><div><div class="gmail_extra">For me it's counter-intuitive that there are two outputs. What is the reason behind?<br>It seems that the use of the <|> affects the rest of the program.<br></div><div class="gmail_extra">It looks strange to me because the two lines situated after the <|> does not look "syntactically" involved, if you see what I mean.<br></div><div class="gmail_extra">Instead I was expecting only one output, with the first thread to finish "wins".<br></div><div class="gmail_extra">In fact I implemented it like that: <a href="http://www.corentindupont.info/blog/posts/Programming/2014-09-23-Nomyx-Language.html#event-alternative-interface" target="_blank">http://www.corentindupont.info/blog/posts/Programming/2014-09-23-Nomyx-Language.html#event-alternative-interface</a><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Cheers<br></div></div></div></div><div dir="ltr"><div><div><div class="gmail_extra">Corentin<br></div></div></div></div><div dir="ltr"><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 27, 2016 at 8:22 PM, Geraldus <span dir="ltr"><<a href="mailto:heraldhoi@gmail.com" target="_blank">heraldhoi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Sorry, here is some links:<div>Wiki paga on GitHub <a href="https://github.com/agocorona/transient/wiki/Transient-tutorial" target="_blank">https://github.com/agocorona/transient/wiki/Transient-tutorial</a></div><div>Programming at specification level <a href="https://github.com/agocorona/transient/wiki/Programming-at-the-specification-level" target="_blank">https://github.com/agocorona/transient/wiki/Programming-at-the-specification-level</a></div></div><br><div class="gmail_quote"><div dir="ltr">пн, 27 июн. 2016 г. в 23:19, Geraldus <<a href="mailto:heraldhoi@gmail.com" target="_blank">heraldhoi@gmail.com</a>>:<br></div><div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi!  Have you looked at Transient by Alberto Gomez Corona?<br><br><div class="gmail_quote"><div dir="ltr">пн, 27 июн. 2016 г. в 18:27, Corentin Dupont <<a href="mailto:corentin.dupont@gmail.com" target="_blank">corentin.dupont@gmail.com</a>>:<br></div></div></div><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>Hi Joachim,<br></div>I agree... I looked hard at them :)<br><a href="https://wiki.haskell.org/Functional_Reactive_Programming" target="_blank">https://wiki.haskell.org/Functional_Reactive_Programming</a><br><br></div>I need a library with a DSL able to create forms on the fly, in a "demand driven" way.<br></div>I.e. if at some point in time the user program needs a boolean from the user, a radio button will be created on the screen of that user. The objective is to retrieve the boolean, creating the form is just a way to do that. Complex forms can be created, capable of generating full ADTs. The styling of the form is not important.<br></div>Other requirements:<br></div>- it should be possible to run the event DSL in a monad different from IO.<br></div>- the event DSL need to be instance of Alternative: events can be put in concurrence, the first to fire wins.<br><br><br><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 27, 2016 at 10:25 AM, Joachim Breitner <span dir="ltr"><<a href="mailto:mail@joachim-breitner.de" target="_blank">mail@joachim-breitner.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Hi,<br>
<span><br>
Am Montag, den 27.06.2016, 09:38 +0200 schrieb Corentin Dupont:<br>
> I need it for the game Nomyx, but couldn't find the features I wanted<br>
> from the existing libraries.<br>
<br>
</span>any chance to extend existing libraries to support what you need?<br>
Library proliferation does not really help the ecosystem.<br>
<br>
Greetings,<br>
Joachim<br>
<span><font color="#888888">--<br>
<br>
Joachim “nomeata” Breitner<br>
  <a href="mailto:mail@joachim-breitner.de" target="_blank">mail@joachim-breitner.de</a> • <a href="https://www.joachim-breitner.de/" rel="noreferrer" target="_blank">https://www.joachim-breitner.de/</a><br>
  XMPP: <a href="mailto:nomeata@joachim-breitner.de" target="_blank">nomeata@joachim-breitner.de</a> • OpenPGP-Key: 0xF0FBF51F<br>
  Debian Developer: <a href="mailto:nomeata@debian.org" target="_blank">nomeata@debian.org</a></font></span><br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br></div>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div></div></blockquote></div></div></div>
</blockquote></div><br></div></div></div></div></blockquote></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Alberto.</div>
</div></div>