Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to bring HSP and Acid-state together in a form with Happstack
    text
    copied!<p>I followed the Happstack Crash Course and now I am trying to bring different things together:</p> <p>From "Type-Safe Form processing using reform" (<a href="http://happstack.com/docs/crashcourse/Reform.html#reform" rel="nofollow">http://happstack.com/docs/crashcourse/Reform.html#reform</a>) I have coded this register form:</p> <pre><code>register :: AcidState UserBase -&gt; ServerPart Response register acid = unXMLGenT $ appTemplate "register" () $ reform (form "/register") "register" (insertAndRenderUser acid) Nothing registerForm insertAndRenderUser :: (Monad m) =&gt; AcidState UserBase -&gt; User -&gt; AppT m XML insertAndRenderUser acid user = &lt;dl&gt; &lt;dt&gt;lastname:&lt;/dt&gt; &lt;dd&gt;&lt;% lastName user %&gt;&lt;/dd&gt; &lt;dt&gt;firstname:&lt;/dt&gt; &lt;dd&gt;&lt;% firstName user %&gt;&lt;/dd&gt; &lt;dt&gt;email:&lt;/dt&gt; &lt;dd&gt;&lt;% email user %&gt;&lt;/dd&gt; &lt;dt&gt;birthday:&lt;/dt&gt; &lt;dd&gt;&lt;% show (birthday user) %&gt;&lt;/dd&gt; &lt;/dl&gt; registerForm :: SimpleForm User registerForm = User (UserId 0) &lt;$&gt; (errorList ++&gt; label "Last name:" ++&gt; (inputText "" `transformEither` required) &lt;++ br) &lt;*&gt; (errorList ++&gt; label "First name:" ++&gt; (inputText "" `transformEither` required) &lt;++ br) &lt;*&gt; (errorList ++&gt; label "E-mail:" ++&gt; (inputText "" `transformEither` required) &lt;++ br) &lt;*&gt; (errorList ++&gt; label "Birthday:" ++&gt; (inputText "" `transformEither` requireDate) &lt;++ br) &lt;* inputSubmit "Register" </code></pre> <p>Now I want to add the registered user when the form is successful. I have coded this UserBase with help of acid-state (<a href="http://happstack.com/docs/crashcourse/AcidState.html#ixset" rel="nofollow">http://happstack.com/docs/crashcourse/AcidState.html#ixset</a>)</p> <pre><code>insertUser :: MonadIO m =&gt; AcidState (EventState InsertUserIntern) -&gt; User -&gt; m (EventResult InsertUserIntern) insertUser acid user = do update' acid (InsertUserIntern user) </code></pre> <p>The snippets work separately but where can I insert <code>insertUser acid user</code> in <code>insertAndRenderUser</code> ?</p> <p>I hope you can help me<br> Thanks<br> Flo</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload