Note that there are some explanatory texts on larger screens.

plurals
  1. POHaskell Snap: mongodb field type error
    primarykey
    data
    text
    <p>I get an error which I can't resolve. The snap application compiles without a problem and everything seems to be ok. But when I render the relevant page in a browser I get this error:</p> <p>A web handler threw an exception. Details: expected ("code" :: Integer) in [ _id: 50b56f19208c2e9a09dccc2b, id: 1.0, code: "hdg435", name: "froggy"]</p> <p>The code value is just a rendom string I picked for testing. I am not sure why an integer is expected?</p> <p>These are the relevant parts of an example snap application.</p> <pre><code>getData :: IO [Document] getData = do pipe &lt;- runIOE $ connect $ host "127.0.0.1" let run act = access pipe master "test" act result &lt;- run (find (select [] "pcs") &gt;&gt;= rest) close pipe return $ either (const []) id result mkSplice :: Document -&gt; Splice AppHandler mkSplice d = runChildrenWithText [dtp "id" d ,dtp "code" d ,dtp "name" d ] dtp :: Text -&gt; Document -&gt; (Text,Text) dtp tag d = (tag, T.pack $ show $ at tag d) recSplice :: Splice AppHandler recSplice = mapSplices mkSplice =&lt;&lt; liftIO getData table :: Handler App App () table = heistLocal (bindSplice "rec" recSplice) $ render "table" </code></pre> <p>The relevant Heist template part of table.tpl is here:</p> <pre><code>&lt;table&gt; &lt;tbody&gt; &lt;rec&gt; &lt;tr&gt;&lt;td&gt;&lt;id/&gt;&lt;/td&gt;&lt;td&gt;&lt;code/&gt;&lt;/td&gt;&lt;td&gt;&lt;name/&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/rec&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>Please let me know what other parts of code need to be posted.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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