2011-09-16 10 views
5

मुझे हैमलेट के साथ एक अजीब समस्या है। मैं एक सूची के माध्यम से फिर से शुरू करने के लिए $ forall का उपयोग करने की कोशिश कर रहा हूं, लेकिन मुझे "स्कोप में नहीं" त्रुटि मिल रही है। मैं Win7 पर हाँओड 0.9.2.2 चला रहा हूँ।

भयानक डिज़ाइन एक तरफ है, किसी को भी कोई विचार है कि मैं गलत कहां जा रहा हूं? "डीबी" के परिवर्तनीय इंटरपोलेशन को हटाने से ठीक निष्पादित हो जाता है।

प्रासंगिक गांव:

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

जब Yesod 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} 

आपके संस्करण में पंक्ति $ कुल के दायरे से बाहर है।

+0

आप दयालु महोदय, बहुत दयालु हैं। – Caleb

संबंधित मुद्दे