2011-09-16 8 views
5

私はhamletに奇妙な問題があります。私は$ forallを使ってリストを反復しようとしていますが、 "範囲外"のエラーが出ています。 Win7でyesod 0.9.2.2を実行しています。

私は間違っていますか? "db"の変数補間を削除すると、きれいに実行できます。

関連ハムレット:

!!! 
<h1> Database List 
<hr> 
<table> 

    <tr> 
     <td> Host 
     <td> Status 
    $forall db <- dbList 
    <tr> 
     <td> #{host db} 

関連するハンドラコード:

data Database = Database {dbType :: DBType, 
         host :: String, 
         user :: String, 
         password :: String 
         } 


dbList = [Database Oracle "cpalmerws" "system" "***", 
      Database Oracle "bdblnx" "system" "***", 
      Database Postgres "localhost" "postgres" "***"] 

getDBStatusR :: Handler RepHtml 
getDBStatusR = do 
    mu <- maybeAuth 
    defaultLayout $ do 
    setTitle "DB Status Page" 
    addWidget $(widgetFile "dbstatus") 

イェソドのdevelの実行しているとき、私はこのエラーを取得しています:中

Handler\DBStatus.hs:47:17: 
    Not in scope: `db' 
    In the result of the splice: 
     $(widgetFile "dbstatus") 
    To see what the splice expanded to, use -ddump-splices 
    In the first argument of `addWidget', namely 
     `$(widgetFile "dbstatus")' 
    In the expression: addWidget ($(widgetFile "dbstatus")) 
Starting development server... 

dist\devel.hs:3:1: 
    Failed to load interface for `Application': 
     it is not a module in the current program, or in any known package. 
Exit code: ExitFailure 1 

答えて

8

あなたのインデントレベルをテンプレートが間違っています:

$forall db <- dbList 
    <tr> 
     <td>#{host db} 

あなたのバージョンでは、行は$ forallの範囲外にあります。

+0

あなたはとても親切です。 – Caleb