我在使用稍微改动过的 Yesod 脚手架时遇到了麻烦。我在 /config/models 中对我的实体进行了如下描述:
Artist
ident Int
value Text
这是我在 /Handler/Artist.hs 的处理程序
{-# LANGUAGE QuasiQuotes, TypeFamilies, GeneralizedNewtypeDeriving, TemplateHaskell,
OverloadedStrings, GADTs, FlexibleContexts #-}
module Handler.Artist where
import Import
import qualified Control.Monad.IO.Class as M
import Text.Hamlet (shamlet)
import Text.Blaze.Html.Renderer.String (renderHtml)
import Database.Persist
import Database.Persist.Sqlite
import Database.Persist.TH
import Control.Monad.IO.Class (liftIO)
getArtistR = concatMap (renderListElement . value) $ artists
where artists = selectList ([] :: [Filter Artist]) []
renderListElement name = renderHtml [shamlet|<li>#{name}|]
(我包括冗余:))
最后,我的错误:
Rebuilding application... (using cabal)
Handler/Artist.hs:14:45: Not in scope: `value'
Build failure, pausing...
我不确定我应该怎么做!我需要$(widgetFile "artist")
在处理程序中投入类似的东西吗?补丁哪里出错了?任何帮助都会很棒。先感谢您!!!