<div dir="ltr">I've been able to use digestive-functors with simple forms successfully
in a snap application; however, I'm getting stuck when trying to handle a
list of hidden inputs. There is something I'm not quite getting on how
to use 'listOf'. Can anyone point me in the right direction? Thanks.<br><br>The rendered html from a previous page includes the following hidden fields:<br><br><pre><span><</span><span>div</span> <span>id</span><span>=</span><span>'</span><span>messageForm</span><span>.</span><span>recipients'</span> <span>class</span><span>=</span><span>'</span><span>inputList'</span><span>></span>
<span><</span><span>input</span> <span>type</span><span>=</span><span>'</span><span>hidden'</span> <span>name</span><span>=</span><span>'</span><span>messageForm</span><span>.</span><span>recipients</span><span>.</span><span>i<wbr>ndices'</span> <span>value</span><span>=</span><span>'0'</span> <span>/></span>
<span><</span><span>input</span> <span>type</span><span>=</span><span>'</span><span>hidden'</span> <span>id</span><span>=</span><span>'</span><span>messageForm</span><span>.</span><span>recipients</span><span>.-</span><span>1</span><span>.</span><span><wbr>email'</span> <span>name</span><span>=</span><span>'</span><span>messageForm</span><span>.</span><span>recipients</span><span>.-</span><span><wbr>1</span><span>.</span><span>email'</span> <span>value</span> <span>/></span>
<span><</span><span>input</span> <span>type</span><span>=</span><span>'</span><span>hidden'</span> <span>id</span><span>=</span><span>'</span><span>messageForm</span><span>.</span><span>recipients</span><span>.</span><span>0</span><span>.</span><span>e<wbr>mail'</span> <span>name</span><span>=</span><span>'</span><span>messageForm</span><span>.</span><span>recipients</span><span>.</span><span>0</span><span><wbr>.</span><span>email'</span> <span>value</span><span>=</span><span>'</span><span>emai1l</span><span>@</span><span>email</span><span>.</span><span>com'</span> <span>/></span>
<span><</span><span>input</span> <span>type</span><span>=</span><span>'</span><span>hidden'</span> <span>id</span><span>=</span><span>'</span><span>messageForm</span><span>.</span><span>recipients</span><span>.</span><span>1</span><span>.</span><span>e<wbr>mail'</span> <span>name</span><span>=</span><span>'</span><span>messageForm</span><span>.</span><span>recipients</span><span>.</span><span>1</span><span><wbr>.</span><span>email'</span> <span>value</span><span>=</span><span>'</span><span>email2</span><span>@</span><span>email</span><span>.</span><span>com'</span> <span>/></span>
<span></</span><span>div</span><span>></span>
The data types are:
<span>data</span> <span>ConfirmMessage</span> <span>=</span> <span>ConfirmMessage</span> <span>{</span>
<span>isoDate</span> <span>::</span> <span>T</span><span>.</span><span>Text</span><span>,</span>
<span>subject</span> <span>::</span> <span>T</span><span>.</span><span>Text</span><span>,</span>
<span>body</span> <span>::</span> <span>T</span><span>.</span><span>Text</span><span>,</span>
<span>action</span> <span>::</span> <span>T</span><span>.</span><span>Text</span><span>,</span>
<span>recipients</span> <span>::</span> <span>[</span><span>Recipient</span><span>]</span>
<span>}</span> <span>deriving</span> <span>(</span><span>Show</span><span>)</span>
<span>data</span> <span>Recipient</span> <span>=</span> <span>Recipient</span> <span>{</span>
<span>email</span> <span>::</span> <span>T</span><span>.</span><span>Text</span>
<span>}</span> <span>deriving</span> <span>(</span><span>Show</span><span>)</span>
<br>The forms are:<br>
<span>messageForm</span> <span>::</span> <span>(</span><span>Monad</span> <span>m</span><span>)</span> <span>=></span> <span>Form</span> <span>T</span><span>.</span><span>Text</span> <span>m</span> <span>ConfirmMessage</span>
<span>messageForm</span> <span>=</span> <span>ConfirmMessage</span>
<span><$></span> <span>"isoDate"</span> <span>.:</span> <span>stringRead</span> <span>"Missing ISOdate"</span> <span>Nothing</span>
<span><*></span> <span>"subject"</span> <span>.:</span> <span>stringRead</span> <span>"Subject required"</span> <span>Nothing</span>
<span><*></span> <span>"body"</span> <span>.:</span> <span>stringRead</span> <span>"Body required"</span> <span>Nothing</span>
<span><*></span> <span>"action"</span> <span>.:</span> <span>stringRead</span> <span>"Missing action"</span> <span>Nothing</span>
<span><*></span> <span>"recipients"</span> <span>.:</span> <span>listOf</span> <span>recipientForm'</span> <span>Nothing</span>
<span>recipientForm'</span> <span>::</span> <span>(</span><span>Monad</span> <span>m</span><span>)</span> <span>=></span> <span>Formlet</span> <span>T</span><span>.</span><span>Text</span> <span>m</span> <span>Recipient</span>
<span>recipientForm'</span><span>=</span> <span>Recipient</span>
<span><$></span> <span>"email"</span> <span>.:</span> <span>stringRead</span> <span>"Missing email"</span> <span>Nothing</span>
<span>Error</span> <span>message</span><span>:</span>
<span>Couldn't</span> <span>match</span> <span>type</span> <span>`</span><span>Text</span><span>.</span><span>Digestive</span><span>.</span><span>Form</span><span>.</span><span>Internal</span><span>.</span><span><wbr>FormTree</span>
<span>m0</span> <span>v0</span> <span>m0</span> <span>Recipient'</span>
<span>with</span> <span>`</span><span>Maybe</span> <span>Recipient</span> <span>-></span> <span>Form</span> <span>T</span><span>.</span><span>Text</span> <span>m</span> <span>Recipient'</span>
<span>Expected</span> <span>type</span><span>:</span> <span>Formlet</span> <span>T</span><span>.</span><span>Text</span> <span>m</span> <span>Recipient</span>
<span>Actual</span> <span>type</span><span>:</span> <span>Text</span><span>.</span><span>Digestive</span><span>.</span><span>Form</span><span>.</span><span>Internal</span><span>.</span><span>F<wbr>ormTree</span>
<span>m0</span> <span>v0</span> <span>m0</span> <span>Recipient</span>
<span>Relevant</span> <span>bindings</span> <span>include</span>
<span>recipientForm'</span> <span>::</span> <span>Formlet</span> <span>T</span><span>.</span><span>Text</span> <span>m</span> <span>Recipient</span>
<span>(</span><span>bound</span> <span>at</span> <span>src</span><span>/</span><span>Handler</span><span>/</span><span>TradeNotifyConfirm</span><span><wbr>.</span><span>hs</span><span>:</span><span>224</span><span>:</span><span>1</span><span>)</span>
<span>In</span> <span>the</span> <span>expression</span><span>:</span>
<span>Recipient</span> <span><$></span> <span>"email"</span> <span>.:</span> <span>stringRead</span> <span>"Missing email"</span> <span>Nothing</span>
<span>In</span> <span>an</span> <span>equation</span> <span>for</span> <span>`</span><span>recipientForm''</span><span>:</span>
<span>recipientForm'</span>
<span>=</span> <span>Recipient</span> <span><$></span> <span>"email"</span> <span>.:</span> <span>stringRead</span> <span>"Missing email"</span> <span>Nothing</span>
<span></span><br></pre>Thanks in advance,<br>Neil</div>