Yesod Hamlet getHomeR 找不到参考
Yesod Hamlet getHomeR can't find reference
getHomeR :: Handler Html
getHomeR = do
wordList <- runDB $ selectList [] [] :: HandlerT App IO [Entity Vocabulary]
defaultLayout
[whamlet|
<ul>
$forall Entity wordid wordItem <- wordList
<li>
<a href=@{HomeR}>#{date wordItem}
|]
我收到这个错误
Variable not in scope: date :: Vocabulary -> a0
虽然我在模型中定义了:
Vocabulary json
word Text
date UTCTime
deriving Show
PS: 我是基于yesod脚手架示例开发的:yesod-postgres
应该是 vocabularyDate
而不是 date
。
根据 yesod book 上的持久部分,
mkPersist sqlSettings [persistLowerCase|
Person
name String
age Int
deriving Show
|]
将生成类似于
的代码
data Person = Person
{ personName :: !String
, personAge :: !Int
}
deriving Show
...
如您所见,字段名称以数据名称为前缀(personName
而不是 name
)。这是 Haskell 中避免名称冲突的标准做法。
getHomeR :: Handler Html
getHomeR = do
wordList <- runDB $ selectList [] [] :: HandlerT App IO [Entity Vocabulary]
defaultLayout
[whamlet|
<ul>
$forall Entity wordid wordItem <- wordList
<li>
<a href=@{HomeR}>#{date wordItem}
|]
我收到这个错误
Variable not in scope: date :: Vocabulary -> a0
虽然我在模型中定义了:
Vocabulary json
word Text
date UTCTime
deriving Show
PS: 我是基于yesod脚手架示例开发的:yesod-postgres
应该是 vocabularyDate
而不是 date
。
根据 yesod book 上的持久部分,
mkPersist sqlSettings [persistLowerCase|
Person
name String
age Int
deriving Show
|]
将生成类似于
的代码data Person = Person
{ personName :: !String
, personAge :: !Int
}
deriving Show
...
如您所见,字段名称以数据名称为前缀(personName
而不是 name
)。这是 Haskell 中避免名称冲突的标准做法。