<p dir="ltr">I'm on mobile now, but you want to use the ^?{} syntax which allows you to pass a pair of route and query string parameters. There's an example in the Shakespeare chapter of the book.</p>
<br><div class="gmail_quote"><div dir="ltr">On Sat, May 27, 2017, 8:34 AM Michael Litchard <<a href="mailto:litchard.michael@gmail.com">litchard.michael@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="m_1525717690137754714gmail-post-text">

<p>Below I have an example from the <a rel="nofollow noreferrer" href="https://www.yesodweb.com/book/forms" target="_blank">Yesod</a> book. The form action maps to a route. How do I pass a value to that route. I know it has something to do with <code>^</code> but I can't see to make it work right.</p>

<pre class="m_1525717690137754714gmail-lang-hs m_1525717690137754714gmail-prettyprint m_1525717690137754714gmail-prettyprinted"><code><span class="m_1525717690137754714gmail-com">{-# LANGUAGE MultiParamTypeClasses #-}</span><span class="m_1525717690137754714gmail-pln">
</span><span class="m_1525717690137754714gmail-com">{-# LANGUAGE OverloadedStrings     #-}</span><span class="m_1525717690137754714gmail-pln">
</span><span class="m_1525717690137754714gmail-com">{-# LANGUAGE QuasiQuotes           #-}</span><span class="m_1525717690137754714gmail-pln">
</span><span class="m_1525717690137754714gmail-com">{-# LANGUAGE TemplateHaskell       #-}</span><span class="m_1525717690137754714gmail-pln">
</span><span class="m_1525717690137754714gmail-com">{-# LANGUAGE TypeFamilies          #-}</span><span class="m_1525717690137754714gmail-pln">
</span><span class="m_1525717690137754714gmail-kwd">import</span><span class="m_1525717690137754714gmail-pln">           Control.Applicative
</span><span class="m_1525717690137754714gmail-kwd">import</span><span class="m_1525717690137754714gmail-pln">           Data.Text           </span><span class="m_1525717690137754714gmail-pun">(</span><span class="m_1525717690137754714gmail-pln">Text</span><span class="m_1525717690137754714gmail-pun">)</span><span class="m_1525717690137754714gmail-pln">
</span><span class="m_1525717690137754714gmail-kwd">import</span><span class="m_1525717690137754714gmail-pln">           Yesod

</span><span class="m_1525717690137754714gmail-kwd">data</span><span class="m_1525717690137754714gmail-pln"> App </span><span class="m_1525717690137754714gmail-pun">=</span><span class="m_1525717690137754714gmail-pln"> App

mkYesod </span><span class="m_1525717690137754714gmail-str">"App"</span><span class="m_1525717690137754714gmail-pln"> </span><span class="m_1525717690137754714gmail-pun">[</span><span class="m_1525717690137754714gmail-pln">parseRoutes</span><span class="m_1525717690137754714gmail-pun">|</span><span class="m_1525717690137754714gmail-pln">
</span><span class="m_1525717690137754714gmail-pun">/</span><span class="m_1525717690137754714gmail-pln"> HomeR GET
</span><span class="m_1525717690137754714gmail-pun">/</span><span class="m_1525717690137754714gmail-pln">input InputR GET
</span><span class="m_1525717690137754714gmail-pun">|]</span></code></pre>

<p>instance Yesod App</p>

<pre class="m_1525717690137754714gmail-lang-hs m_1525717690137754714gmail-prettyprint m_1525717690137754714gmail-prettyprinted"><code><span class="m_1525717690137754714gmail-kwd">instance</span><span class="m_1525717690137754714gmail-pln"> RenderMessage App FormMessage </span><span class="m_1525717690137754714gmail-kwd">where</span><span class="m_1525717690137754714gmail-pln">
    renderMessage </span><span class="m_1525717690137754714gmail-kwd">_</span><span class="m_1525717690137754714gmail-pln"> </span><span class="m_1525717690137754714gmail-kwd">_</span><span class="m_1525717690137754714gmail-pln"> </span><span class="m_1525717690137754714gmail-pun">=</span><span class="m_1525717690137754714gmail-pln"> defaultFormMessage

</span><span class="m_1525717690137754714gmail-kwd">data</span><span class="m_1525717690137754714gmail-pln"> Person </span><span class="m_1525717690137754714gmail-pun">=</span><span class="m_1525717690137754714gmail-pln"> Person
    </span><span class="m_1525717690137754714gmail-pun">{</span><span class="m_1525717690137754714gmail-pln"> personName </span><span class="m_1525717690137754714gmail-pun">::</span><span class="m_1525717690137754714gmail-pln"> Text
    </span><span class="m_1525717690137754714gmail-pun">,</span><span class="m_1525717690137754714gmail-pln"> personAge  </span><span class="m_1525717690137754714gmail-pun">::</span><span class="m_1525717690137754714gmail-pln"> Int
    </span><span class="m_1525717690137754714gmail-pun">}</span><span class="m_1525717690137754714gmail-pln">
    </span><span class="m_1525717690137754714gmail-kwd">deriving</span><span class="m_1525717690137754714gmail-pln"> Show

getHomeR </span><span class="m_1525717690137754714gmail-pun">::</span><span class="m_1525717690137754714gmail-pln"> Handler Html
getHomeR </span><span class="m_1525717690137754714gmail-pun">=</span><span class="m_1525717690137754714gmail-pln"> defaultLayout
    </span><span class="m_1525717690137754714gmail-pun">[</span><span class="m_1525717690137754714gmail-pln">whamlet</span><span class="m_1525717690137754714gmail-pun">|</span><span class="m_1525717690137754714gmail-pln">
        </span><span class="m_1525717690137754714gmail-pun"><</span><span class="m_1525717690137754714gmail-pln">form action</span><span class="m_1525717690137754714gmail-pun">=@{</span><span class="m_1525717690137754714gmail-pln">InputR</span><span class="m_1525717690137754714gmail-pun">}></span><span class="m_1525717690137754714gmail-pln">  </span><span class="m_1525717690137754714gmail-pun"><---</span><span class="m_1525717690137754714gmail-pln"> problem line </span><span class="m_1525717690137754714gmail-com">-- want to do this <form action=@{InputR ^haskellValue}></span><span class="m_1525717690137754714gmail-pln">
            </span><span class="m_1525717690137754714gmail-pun"><</span><span class="m_1525717690137754714gmail-pln">p</span><span class="m_1525717690137754714gmail-pun">></span><span class="m_1525717690137754714gmail-pln">
                My name is
                </span><span class="m_1525717690137754714gmail-pun"><</span><span class="m_1525717690137754714gmail-pln">input </span><span class="m_1525717690137754714gmail-kwd">type</span><span class="m_1525717690137754714gmail-pun">=</span><span class="m_1525717690137754714gmail-pln">text name</span><span class="m_1525717690137754714gmail-pun">=</span><span class="m_1525717690137754714gmail-pln">name</span><span class="m_1525717690137754714gmail-pun">></span><span class="m_1525717690137754714gmail-pln">
                and I am
                </span><span class="m_1525717690137754714gmail-pun"><</span><span class="m_1525717690137754714gmail-pln">input </span><span class="m_1525717690137754714gmail-kwd">type</span><span class="m_1525717690137754714gmail-pun">=</span><span class="m_1525717690137754714gmail-pln">text name</span><span class="m_1525717690137754714gmail-pun">=</span><span class="m_1525717690137754714gmail-pln">age</span><span class="m_1525717690137754714gmail-pun">></span><span class="m_1525717690137754714gmail-pln">
                years old</span><span class="m_1525717690137754714gmail-pun">.</span><span class="m_1525717690137754714gmail-pln">
                </span><span class="m_1525717690137754714gmail-pun"><</span><span class="m_1525717690137754714gmail-pln">input </span><span class="m_1525717690137754714gmail-kwd">type</span><span class="m_1525717690137754714gmail-pun">=</span><span class="m_1525717690137754714gmail-pln">submit value</span><span class="m_1525717690137754714gmail-pun">=</span><span class="m_1525717690137754714gmail-str">"Introduce myself"</span><span class="m_1525717690137754714gmail-pun">></span><span class="m_1525717690137754714gmail-pln">
    </span><span class="m_1525717690137754714gmail-pun">|]</span><span class="m_1525717690137754714gmail-pln">

getInputR </span><span class="m_1525717690137754714gmail-pun">::</span><span class="m_1525717690137754714gmail-pln"> Text </span><span class="m_1525717690137754714gmail-pun">-></span><span class="m_1525717690137754714gmail-pln"> Handler Html
getInputR label </span><span class="m_1525717690137754714gmail-pun">=</span><span class="m_1525717690137754714gmail-pln"> </span><span class="m_1525717690137754714gmail-kwd">do</span><span class="m_1525717690137754714gmail-pln">
    person </span><span class="m_1525717690137754714gmail-pun"><-</span><span class="m_1525717690137754714gmail-pln"> runInputGet </span><span class="m_1525717690137754714gmail-pun">$</span><span class="m_1525717690137754714gmail-pln"> Person
                </span><span class="m_1525717690137754714gmail-pun"><$></span><span class="m_1525717690137754714gmail-pln"> ireq textField label
                </span><span class="m_1525717690137754714gmail-pun"><*></span><span class="m_1525717690137754714gmail-pln"> ireq intField </span><span class="m_1525717690137754714gmail-str">"age"</span><span class="m_1525717690137754714gmail-pln">
    defaultLayout </span><span class="m_1525717690137754714gmail-pun">[</span><span class="m_1525717690137754714gmail-pln">whamlet</span><span class="m_1525717690137754714gmail-pun">|<</span><span class="m_1525717690137754714gmail-pln">p</span><span class="m_1525717690137754714gmail-pun">>#{</span><span class="m_1525717690137754714gmail-pln">show person</span><span class="m_1525717690137754714gmail-pun">}|]</span><span class="m_1525717690137754714gmail-pln">

main </span><span class="m_1525717690137754714gmail-pun">::</span><span class="m_1525717690137754714gmail-pln"> IO </span><span class="m_1525717690137754714gmail-pun">()</span><span class="m_1525717690137754714gmail-pln"> 
main </span><span class="m_1525717690137754714gmail-pun">=</span><span class="m_1525717690137754714gmail-pln"> warp </span><span class="m_1525717690137754714gmail-lit">3000</span><span class="m_1525717690137754714gmail-pln"> App</span></code></pre>
    </div></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>