我正在尝试在 Yesod 应用程序中持久化。我的模型文件包含
Job
issuer MemberId
addDate UTCTime
lastDate UTCTime
title Text
description Text
deriving Show Read
还有我的处理程序:
getProfileR :: Handler RepHtml
getProfileR = do
jobs <- runDB $ selectList [] [Desc JobAddDate]
defaultLayout $ do
setTitle "title"
$(widgetFile "profile")
在 profile.hamlet 中,我循环遍历对象
$forall Job issuer addDate lastDate title description <- jobs
<p>#{issuer}
但是,我收到以下错误
Handler/Profile.hs:36:18:
Couldn't match type `Entity' with `JobGeneric'
In the return type of a call of `selectList'
In the second argument of `($)', namely
`selectList [] [Desc JobAddDate]'
In a stmt of a 'do' block:
jobs <- runDB $ selectList [] [Desc JobAddDate]
Handler/Profile.hs:36:18:
Kind incompatibility when matching types:
t0 :: (* -> *) -> * -> *
JobGeneric Database.Persist.GenericSql.Raw.SqlPersist :: *
In the return type of a call of `selectList'
In the second argument of `($)', namely
`selectList [] [Desc JobAddDate]'
In a stmt of a 'do' block:
jobs <- runDB $ selectList [] [Desc JobAddDate]
Build failure, pausing...
其中第 36 行是 runDB 行。
作为 Haskell 的新手,我不知道出了什么问题。我正在关注Yesod Book。不幸的是,他们避开了 Scaffolded Site,所以我无法完全模仿他们的代码。