Haskell 在引入参数后编译yesod路由时遇到问题

Haskell 在引入参数后编译yesod路由时遇到问题,haskell,yesod,hamlet,Haskell,Yesod,Hamlet,我正在运行一个修改后的 之前未使用DBEntitySchemaId类型的参数id。 自从介绍它以来,我越来越喜欢它 Handler/Entity.hs:146:34: Couldn't match type ‘DBEntitySchemaId -> Route App’ with ‘Route (HandlerSite (WidgetT App IO))’ Expected type: WidgetT

我正在运行一个修改后的

之前未使用DBEntitySchemaId类型的参数id。 自从介绍它以来,我越来越喜欢它

Handler/Entity.hs:146:34:
    Couldn't match type ‘DBEntitySchemaId -> Route App’
                  with ‘Route (HandlerSite (WidgetT App IO))’
    Expected type: WidgetT
                    App IO ((DBEntitySchemaId -> Route App) -> [(Text, Text)] -> Text)
     Actual type: WidgetT
                    App
                    IO
                    (Route (HandlerSite (WidgetT App IO)) -> [(Text, Text)] -> Text)
   In the first argument of ‘(>>=)’, namely ‘getUrlRenderParams’
   In a stmt of a 'do' block:
     (getUrlRenderParams
      >>=
        (\ urender_akdM
           -> (asWidgetT GHC.Base.. toWidget)
                (toHtml (\ u_akdN -> urender_akdM u_akdN [] EntityR))))
指使用defaultLayout的行。 有关守则如下:

getEntityR :: DBEntitySchemaId -> Handler Html
getEntityR id = do
  oldEntities <- runDB $ selectList [DBEntityDbentitySchemaId ==. id] []
  fields <- runDB $ selectList [DBFieldDbentitySchemaId ==. id, DBFieldFieldTypeId ==. (toSqlKey 1)] []
  mauthId <- maybeAuthId
  ((res, widget), enctype) <- runFormPost (form fields)
  case (mauthId,res) of
    (Just userId, FormSuccess (attributeValues)) -> do
      setMessageI $ MsgSubmittedKarma
      let entity = DBEntity "Test" id
      entId <- runDB $ insert entity
      let fieldsNVals = zip fields attributeValues
      let einfuegen field attributeValue = case (field, attributeValue) of
                                      ((Entity fldId _), (FormSuccess val)) -> do
                                         a <- runDB $ insert (Attribute {attributeEntityId = entId, attributeDbfieldId = fldId, attributeStringValue =  val})
                                         return (Just a)
                                      _ -> return Nothing
      _ <- forM fieldsNVals (\(field, attributeValue) -> einfuegen field attributeValue)

      redirect $ (EntityR id)
    _ -> do        
      --render <- getUrlRenderParams
      --return $ renderHtml $ [hamlet|
      defaultLayout [whamlet|
          $if null oldEntities
              <p>There are no entities
          $else
              <ul>
                  $forall Entity entityId entity  <- oldEntities
                      <li>
                          <p>#{dBEntityName entity}
          $if mauthId == Nothing
              <form method=post action=@{EntityR} enctype=#{enctype}>
                  <input type=submit value=_{MsgPleaseLogin}>
          $else
              <form method=post action=@{EntityR} enctype=#{enctype}>
                  ^{widget}
                  <input type=submit>
      |]

这其中的一些变化源于


我想只有一个小的修改要做。然而,我对《whamlet/哈姆雷特》的理解并不太深刻。所以我在这里发布这篇文章,以防它是一个小问题。我完全明白我需要投入更多的工作,我只是在谷歌搜索我的问题时遇到了麻烦。所以请容忍我。

修改路由后,您忘记将新添加的参数传递到
{EntityR}
插值,类似这样:
{EntityR param}

如果我理解正确,您需要向
{EntityR}
添加一些参数,如下:
{EntityR param}
您完全正确,我看错了地方(因为行号是指包含[whamlet |)的行)。请发布答案,以便我将问题标记为已回答。非常感谢。
[whamlet| 
[whamlet|@{getEntityR}/#{id}|
[whamlet||@?{urlParams id}|