Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8921649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:35:56+00:00 2026-06-15T06:35:56+00:00

I get an error which I can’t resolve. The snap application compiles without a

  • 0

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:

A web handler threw an exception. Details:
expected (“code” :: Integer) in [ _id: 50b56f19208c2e9a09dccc2b, id: 1.0, code: “hdg435”, name: “froggy”]

The code value is just a rendom string I picked for testing. I am not sure why an integer is expected?

These are the relevant parts of an example snap application.

getData :: IO [Document]
getData = do
  pipe <- runIOE $ connect $ host "127.0.0.1"
  let run act = access pipe master "test" act
  result <- run (find (select [] "pcs") >>= rest)
  close pipe
  return $ either (const []) id result

mkSplice :: Document -> Splice AppHandler
mkSplice d = runChildrenWithText [dtp "id" d
                                 ,dtp "code" d
                                 ,dtp "name" d
                                 ]


dtp :: Text -> Document -> (Text,Text)
dtp tag d = (tag, T.pack $ show $ at tag d)

recSplice :: Splice AppHandler
recSplice = mapSplices mkSplice =<< liftIO getData

table :: Handler App App ()
table = heistLocal (bindSplice "rec" recSplice) $ render "table"

The relevant Heist template part of table.tpl is here:

<table>
  <tbody>
    <rec>
      <tr><td><id/></td><td><code/></td><td><name/></td></tr>
    </rec>
  </tbody>
</table>

Please let me know what other parts of code need to be posted.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:35:57+00:00Added an answer on June 15, 2026 at 6:35 am

    When I compile your dtp function I get:

    import Data.Bson
    import Data.Text (Text)
    import qualified Data.Text as T
    
    dtp :: Text -> Document -> (Text,Text)
    dtp tag d = (tag, T.pack $ show $ at tag d)
    
    Ambiguous type variable `a0' in the constraints:
      (Show a0)
      [...]
    

    which makes perfect sense. It seems like in your case it’s defaulting to Integer when you really want String. You can try adding a signature or better yet, just:

    dtp tag d = (tag, at tag d)
    

    If you want this to work for other types, you’ll have to work harder.

    UPDATE

    Here’s a GHCi session that illustrates the problem and how GHCi seems to default the Show instance to Integer:

    Prelude Data.Bson> show $ at "hello" ["hello" =: "world"]
    "*** Exception: expected ("hello" :: Integer) in [ hello: "world"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am tring to add dll file to my Silverlight application but get error
I've searched online and on here but can't find anything which seems to fit
I get the above error message (which I googled and found is something to
I get a compile error, which I'm slightly confused about. This is on VS2003.
I get an I/O Error 1784 due to blockwrite in the following code which
Why do I get error in this code?Even if i do not link but
Why I get error with this query on my live server but not on
I use the following jquery statements but i get error in this function onGetDataSuccess(result)
Hi. I created a project which can send email using JavaMail. But when I
I have a stored procedure which can return a error this example its going

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.