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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:52:09+00:00 2026-06-09T05:52:09+00:00

I am trying to get the blog example to run, but there is a

  • 0

I am trying to get the blog example to run, but there is a problem with types in some handler functions and I don’t know how to fix it.

The example I am trying to run is posted here:
Yesod blog example
I changed a little bit of it, I added types to defaultLayout function and made it an instance of Yesod to get rid of double definitions.

defLayout :: GWidget a Blog () -> GHandler a Blog RepHtml
defLayout inside = do
  mmsg <- getMessage
  pc <- widgetToPageContent $ do
      toWidget [lucius|
body {
width: 760px;
margin: 1em auto;
font-family: sans-serif;
}
textarea {
width: 400px;
height: 200px;
}
#message {
color: #900;
}
|]
      inside 
  hamletToRepHtml [hamlet|
$doctype 5
<html>
    <head>
        <title>#{pageTitle pc}
        ^{pageHead pc}
    <body>
        $maybe msg <- mmsg
            <div #message>#{msg}
        ^{pageBody pc}
|]

instance Yesod Blog where
    approot = ApprootStatic "http://localhost:3000"
    defaultLayout = defLayout

These are the functions that give me problems:

getBlogR :: Handler RepHtml
getBlogR = do
  muser <- maybeAuth
  entries <- runDB $ selectList [] [Desc EntryPosted]
  ((_, entryWidget), enctype) <- generateFormPost entryForm
  defaultLayout $ do
             setTitleI MsgBlogArchiveTitle
             [whamlet|
$if null entries
    <p>_{MsgNoEntries}
$else
    <ul>
        $forall Entity entryId entry <- entries
            <li>
                <a href=@{EntryR entryId}>#{entryTitle entry}
$maybe Entity _ user <- muser
    $if isAdmin user
        <form method=post enctype=#{enctype}>
              ^{entryWidget}
              <div>
                  <input type=submit value=_{MsgNewEntry}>
$nothing
    <p>
         <a href=@{AuthR LoginR}>_{MsgLoginToPost}
|]

getEntryR :: EntryId -> Handler RepHtml
getEntryR entryId = do
  (entry, comments) <- runDB $ do
          entry <- get404 entryId
          comments <- selectList [] [Asc CommentPosted]
          return (entry, map entityVal comments)
  muser <- maybeAuth
  ((_, commentWidget), enctype) <- generateFormPost (commentForm entryId)
  defaultLayout $ do
    setTitleI $ MsgEntryTitle $ entryTitle entry
    [whamlet|
<h1>#{entryTitle entry}
<article>#{entryContent entry}
    <section .comments>
        <h1>_{MsgCommentsHeading}
        $if null comments
            <p>_{MsgNoComments}
        $else
             $forall Comment _entry posted _user name text <- comments
                 <div .comment>
                      <span .by>#{name}
                      <span .at>#{show posted}
                      <div .content>#{text}
        <section>
            <h1>_{MsgAddCommentHeading}
            $maybe _ <- muser
                <form method=post enctype=#{enctype}>
                    ^{commentWidget}
                    <div>
                        <input type=submit value=_{MsgAddCommentButton}>
            $nothing
                <p>
                    <a href=@{AuthR LoginR}>_{MsgLoginToComment}
|]

Here is the output I get when I try to run it:

blog.hs:147:4:
    Couldn't match expected type `GWidget Blog Blog ()'
                with actual type `(t0, t1)'
    In the pattern: (_, entryWidget)
    In the pattern: ((_, entryWidget), enctype)
    In a stmt of a 'do' block:
      ((_, entryWidget), enctype) <- generateFormPost entryForm

blog.hs:202:4:
    Couldn't match expected type `GWidget Blog Blog ()'
                with actual type `(t0, t1)'
    In the pattern: (_, commentWidget)
    In the pattern: ((_, commentWidget), enctype)
    In a stmt of a 'do' block:
      ((_, commentWidget), enctype) <- generateFormPost
                                         (commentForm entryId)
  • 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-09T05:52:10+00:00Added an answer on June 9, 2026 at 5:52 am

    The type of generateFormPost has changed since the blog article, it used to be

    generateFormPost :: RenderMessage master FormMessage =>
                        (Html -> MForm sub master (FormResult a, xml)) ->
                        GHandler sub master ((FormResult a, xml), Enctype)
    

    in yesod-form-0.4.* but now it is

    generateFormPost :: RenderMessage master FormMessage => 
                        (Markup -> MForm sub master (FormResult a, xml)) -> 
                        GHandler sub master (xml, Enctype)
    

    The type error should [I think, never used yesod] go away if you use yesod-form < 1, or if you replace

    ((_, entryWidget), enctype) <- generateFormPost entryForm
    

    with

    (entryWidget, enctype) <- generateFormPost entryForm
    

    to reflect the change in the type of generateFormPost.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to get the funnelweb blog application to run on my machine, ive
I am trying to get some comments off the car blog, Jalopnik . It
I am trying to get a url structure like this. http://example.com/blog/1/title-name-goes-here My main urls
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
Im trying to get the last string from a URL for example... http://www.mywebsite/blog/this-post I
ref: http://boedesign.com/blog/2008/06/08/imagetick-for-jquery/ I'm trying to get the aformentioned example working in a setup with
I am trying to get the index-page of a Wordpress-blog show some very specific
WordPress has been installed as a blog into osCommerce. I'm trying to get the
i'm trying to get the list of mime types known to an IIS server
I'm trying to get /blog in order to put in url_pathname. var link =

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.