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 8845465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:44:50+00:00 2026-06-14T11:44:50+00:00

I’m changing my existing Yesod application to run on a SQL backend instead of

  • 0

I’m changing my existing Yesod application to run on a SQL backend instead of mongo. The generated table structure is more strict then the mongo backend. Foreign key references should be created correctly on insert.

postFeedingsR :: Handler RepJson
postFeedingsR  = do
  muser <- maybeAuth
  parsedFeeding <- parseJsonBody_ --get content as JSON
  let userId = getUserId muser
  let feedingWithUser = Feeding (feedingDate parsedFeeding) (feedingSide parsedFeeding) (feedingTime parsedFeeding) (feedingExcrements parsedFeeding) (feedingRemarks parsedFeeding) userId --should be linked to user..
  fid <- runDB $ insert feedingWithUser --store in database
  --runDB $ update fid [ FeedingUserId =. userId ] --Old mongo style of linking the feeding to the user
  sendResponseCreated $ FeedingR fid --return the id

I try to update the Entity I get from parseJsonBody with the user UID from the maybeAuth. However this gives me the following error:

No instance for (aeson-0.6.0.2:Data.Aeson.Types.Class.FromJSON
                   (FeedingGeneric backend0))
  arising from a use of `parseJsonBody_'
Possible fix:
  add an instance declaration for
  (aeson-0.6.0.2:Data.Aeson.Types.Class.FromJSON
     (FeedingGeneric backend0))
In a stmt of a 'do' block: parsedFeeding <- parseJsonBody_
In the expression:
  do { muser <- maybeAuth;
       parsedFeeding <- parseJsonBody_;
       let userId = getUserId muser;
       let feedingWithUser
             = Feeding
                 (feedingDate parsedFeeding)
                 (feedingSide parsedFeeding)
                 (feedingTime parsedFeeding)
                 (feedingExcrements parsedFeeding)
                 (feedingRemarks parsedFeeding)
                 userId;
       .... }
In an equation for `postFeedingsR':
    postFeedingsR
      = do { muser <- maybeAuth;
             parsedFeeding <- parseJsonBody_;
             let userId = ...;
             .... }

I’m not sure why this happens. Could anyone put me in the right direction to solve this?

  • 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-14T11:44:52+00:00Added an answer on June 14, 2026 at 11:44 am

    Solved by changing the auth line to:

    Entity uid u <- requireAuth
    

    and by adding the function:

    addUserToFeeding :: UserId -> Feeding -> Feeding                                                                                                                                                            
    addUserToFeeding uid Feeding {feedingDate=date, feedingSide=side, feedingTime=time, feedingExcrements=ex, feedingRemarks=remarks} = Feeding date side time ex remarks uid     
    

    to create a new Feeding with associated user. This Feeding can then be stored in the normal way in Yesod:

    let feedingWithUser = addUserToFeeding uid parsedFeeding                                                                                                                                              
    fid <- runDB $ insert feedingWithUser --store in database                                
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
In my XML file chapters tag has more chapter tag.i need to display chapters
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.