2011-09-16 18 views
5

Hamlet ile garip bir sorun yaşıyorum. Bir liste üzerinden yineleme yapmak için $ forall kullanmaya çalışıyorum, ancak "Kapsam olarak değil" hatasını almaya devam ediyorum. Win7'de yesod 0.9.2.2 çalışıyorum.

Korkunç bir tasarım bir yana, herkes nerede yanlış gittiğime dair bir fikriniz var mı? "Db" değişken enterpolasyonunu kaldırmak, düzgün çalışmasına izin verir.

ilgili köy:

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

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

ilgili işleyici kodu:

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") 

Yesod'dan devel çalıştırırken bu hatayı alıyorum: içinde

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 

cevap

8

Sizin girinti düzeyi şablon yanlış:

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

Sizin sürümünüzde satır $ forall'ın kapsamı dışındadır.

+0

Çok iyisiniz, çok naziksiniz. – Caleb