<div dir="ltr">I have a similar problema with the ids of formlets of different branches of execution. For example in the first case statement the branch represented can be one or the other depending on the previous user response. The identifiers of each branch must be different or else, the server application will be confused by misreading states (values in my case) of different branches. For this purpose each branch has a &quot;pageflow&quot; call that add a new prefix to the identifiers and initialize a counter used to compose a sequence of suffixes for each branch, so that each element has an unique identifier and the identifiers of one branch do not collide with the ones of the other branch. Is this  similar and hopefully applicable to your problema?</div>

<div class="gmail_extra"><br><br><div class="gmail_quote">2013/6/22 Anton Tayanovskyy <span dir="ltr">&lt;<a href="mailto:anton.tayanovskyy@gmail.com" target="_blank">anton.tayanovskyy@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">Our team at IntelliFactory has worked with &quot;monadic&quot; formlets for a while, we call them &quot;flowlets&quot;, in the context of WebSharper/F#. We even have an obscure paper out there about it. The difference with your approach is that we are working directly with DOM nodes and imperative widgets to execute entirely in the browser in JavaScript.  This makes for nice looking demos, but unfortunately comes with a price. With imperative widgets, identity matters. If you work with console text output or re-creating an HTML document, you simply model what you present to the user with a tree, with inductively defined equivalence. In DOM world, however, two HTML trees with an input textbox may serialize equivalently but be distinct, in a sense that the textboxes have distinct identity and hidden state (such as focus), and substituting one for another will be noticed by the user. To this day I have not been able to come up with a convincing simple model and a notion of equivalence that would take that into account and allow to prove monadic laws to hold for the flowlet combinators. I suspect it should be possible though and even likely done already :) <div>



<div><div><div><div><br></div><div><div>Thanks,</div><div><br></div><div>--A<br><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Sat, Jun 22, 2013 at 12:49 AM, Daniel Frumin <span dir="ltr">&lt;<a href="mailto:difrumin@gmail.com" target="_blank">difrumin@gmail.com</a>&gt;</span> wrote:<br>




</div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div><div class="h5"><div dir="auto"><div>This looks interesting. I&#39;ll be following the development of it</div>

<div><div><div>
<br>On Jun 20, 2013, at 2:56 PM, &quot;Alberto G. Corona &quot; &lt;<a href="mailto:agocorona@gmail.com" target="_blank">agocorona@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div>Here is the example with better rendering and additional information as well as some identifies issues to be solved.</div>




<div> </div><div><a href="http://haskell-web.blogspot.com.es/2013/06/the-promising-land-of-monadic-formlets.html" target="_blank">http://haskell-web.blogspot.com.es/2013/06/the-promising-land-of-monadic-formlets.html</a></div>






<div> </div><div>And  I made strong statements there.</div><div> </div><div>What do you think? If you have questions or want to be involved in the development of this and other related concepts, please send me a message.</div>






</div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/6/20 Alberto G. Corona <span dir="ltr">&lt;<a href="mailto:agocorona@gmail.com" target="_blank">agocorona@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">






<div dir="ltr"><div>I don´t know how, but the google mail has changed the applicative functor operator after (,) Left and Rigth by  &quot;&lt;-&quot;.</div><div> </div><div> </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">







2013/6/19 Alberto G. Corona <span dir="ltr">&lt;<a href="mailto:agocorona@gmail.com" target="_blank">agocorona@gmail.com</a>&gt;</span><div><div><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">







<div dir="ltr"><div>Hi, </div><div> </div><div>This is just to let you know the promising results of some experimentation:</div><div> </div><div>Formlets are about applicative instances, but what about monadic instances? What a Monad instance of formlets means? I recently experimented with this and the results are very interesting and powerful- It mixes the best of web forms, with the flexibility of console applications. ???!!!!!!</div>









<div> </div><div> </div><div>Althoug this example is for the formlets of the <a href="https://github.com/agocorona/MFlow" target="_blank">MFlow </a>framework , it can be ported to other formlet implementations. Although the MFLow formlets include web formatting that is not supported in other formlets implementations. Static HTML templating don´t work well with monadic formlets, so it is important to include the formatting as a  part of the computation:</div>









<div> </div><div>import MFlow.Wai.Blaze.Html.All</div><div> </div><div>dynamicForm= wform $ do<br>      (n,s) &lt;- (,) &lt;- p &lt;&lt; &quot;Who are you?&quot;<br>                   ++&gt; getString Nothing  &lt;! hint &quot;name&quot;     &lt;++ br<br>









                   &lt;*&gt; getString Nothing  &lt;! hint &quot;surname&quot;  &lt;++ br<br>                   &lt;** submitButton &quot;ok&quot; &lt;++ br<br>                  <br>      flag &lt;- b &lt;&lt; &quot;do you &quot; ++&gt; getRadio[radiob &quot;work?&quot;,radiob &quot;study?&quot;] &lt;++ br<br>









     <br>      r&lt;-case flag of<br>         &quot;work&quot; -&gt; pageFlow &quot;l&quot;<br>                     $ Left  &lt;- b &lt;&lt; &quot;do you enjoy your work? &quot;<br>                                ++&gt; getBool True &quot;yes&quot; &quot;no&quot;<br>









                                &lt;** submitButton &quot;ok&quot;  &lt;++ br<br>                            <br>         &quot;study&quot;-&gt; pageFlow &quot;r&quot;<br>                     $ Right &lt;- b &lt;&lt; &quot;do you study in &quot;<br>









                                  ++&gt; getRadio[radiob &quot;University&quot;<br>                                         ,radiob &quot;High School&quot;]<br>                                    <br>      p &lt;&lt; (&quot;You are &quot;++n++&quot; &quot;++s) ++&gt;<br>









       case r of<br>         Left fl -&gt;   p &lt;&lt; (&quot;You work and it is &quot; ++ show fl ++ &quot; that you enjoy your work&quot;)<br>                        ++&gt; noWidget</div><div> </div><div>         Right stu -&gt; p &lt;&lt; (&quot;You study at the &quot; ++ stu)<br>








                        ++&gt; noWidget</div><div> </div><div> </div><div>hint s= [(&quot;placeholder&quot;,s)]<br>
onClickSubmit= [(&quot;onclick&quot;,&quot;this.form.submit()&quot;)]<br>radiob s n= text s ++&gt; setRadio s n &lt;! onClickSubmit<br></div><div> </div><div>Here wform, getBool, getString , getRadio etc are formlet elements</div>









<div> </div><div>The first sentence is an applicative composition that generate a 2 tuple, to show that applicative and monadic can be mixed.  the operations ++&gt; add html to the formlet. the operatior &lt;! add attributes to the formlet element.. noWidget is a dumb formlet that does not validate.</div>









<div> </div><div>The second monadic statement is an election between two options. The beauty of the monadic instance is that the rest of the form can vary depending on the previous answers.  Since the formlets validate the input, unless the election is made, the radio will not validate, so the monadic execution will be aborted beyond any unanswered question, so nothing will appear after the question. The rest of the form will appear when the user choose one of the two options. once one or the other option is chosen, then another binary question is presented. (either he likes his work or where he study).  When the questions are finised, the results are presented.<br clear="all">









</div><div>I hope that you get the idea. The benefit is not only the familiar coding and presentation of a sequential console application: Since the form encloses all the fields, At any time the user can change previous inputs and the form will reflect these changes. For example if the user change from work to study (second statements) the &quot;where do you study will appear and the work related questions and answers will disappear. That is wonderfully useful for heavily interactive applications.</div>









<div><br>There is  a problem however and it is the issue of the formlet identifiers. Unlike in an applicative presentation, now the number and type of the formlets will vary, so the response to a previous form create a new kind of form, and the post response can be misinterpreted. To avoid that , the  pageFlow call creates fixed field labels for each branch of execution.</div>








<div> </div><div>I will release a version of MFlow that support this kind of monadic composition of fomlets, but In essence it is nothing but to add Monad instance to formlets. A single server procedure, that executes the formlet code can support all the interaction so any framework can do it. The usability of that is huge:It is possible to interact in a web page in a console style with questions and answers with the versatitly of a dynamic foms: Any modification in the form change the subsequent flow of interaction. Another application of this monadic style is to ease multistep processes such are registration, check-out and payment ad so on. Even a entire interactive dynamic application can be coded in a single page.<div>








 </div><div>And no javascript is needed!.</div><div> </div></div><div> </div><div>To run this formlet in MFlow: </div><div> </div><div>main=do</div><div>  addMessageFlows<br>       [(&quot;&quot;    , transient $ runFlow  $ ask dynamicForm )]<br>








<br>   wait $ run port waiMessageFlow</div>
<div> </div><div> </div><div>This video show how the presentation of this example vary with the user input:</div><div> </div><div><a href="http://youtu.be/DryBQc9agFg" target="_blank"><font color="#0066cc">http://youtu.be/DryBQc9agFg</font></a> </div>








<div>      </div><div>
<div><div style="width:100%"><span></span>           </div></div><div>        <br>
</div></div><div>I hope that you find the idea interesting.  If you want to experiment with this in MFlow, I have to say that the implementation of this feature is in an early stage. The code is in the head branch</div><div>








 </div><div><a href="https://github.com/agocorona/MFlow/tree/head" target="_blank">https://github.com/agocorona/MFlow/tree/head</a></div><span><font color="#888888"><div> </div><div> </div><div><br>Alberto.
</div></font></span></div>
</blockquote></div></div></div><span><font color="#888888"><br><br clear="all"><br>-- <br>Alberto.
</font></span></div>
</blockquote></div><br><br clear="all"><br>-- <br>Alberto.
</div>
</div></blockquote></div></div><blockquote type="cite"><div><span>_______________________________________________</span><br><span>web-devel mailing list</span><br><span><a href="mailto:web-devel@haskell.org" target="_blank">web-devel@haskell.org</a></span><br>




<span><a href="http://www.haskell.org/mailman/listinfo/web-devel" target="_blank">http://www.haskell.org/mailman/listinfo/web-devel</a></span><br></div></blockquote></div><br></div></div>_______________________________________________<br>





Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Kind Regards,<br>Anton Tayanovskyy<br><br>WebSharper™ - type-safe JavaScript in F#<br><a href="http://intellifactory.com" target="_blank">http://intellifactory.com</a><br>





</font></span></div></div></div></div></div></div></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Alberto.
</div>