2013-09-27 50 views
0
module sayhello 
(inChinese 
, inSpanish 
) where 
inChinese = "Ni Hao" 
inSpanish= "Hola" 

import sayhello 

main = do 

    print sayhello.inChinese 
    print sayhello.inSpanish 

我從這段代碼有錯誤"module.hs:1:8: parse error on input 'sayhello'" 我不明白爲什麼,需要你的幫助,感謝哈斯克爾模塊,輸入解析錯誤「的SayHello」「'

編輯:。 1對問題發現,我應該用大寫作爲模塊名

  1. 我得到了另外一個問題: 它表明:

    產量爲紅色用-o定向,但沒有輸出將生成 ,因爲沒有主模塊。

這是爲什麼?謝謝

回答

2

您必須在module ModName (export list) where和您的實際代碼之後擁有所有導入語句。另外,您不需要導入您當前所在的模塊:

module sayhello 
    (inChinese 
    , inSpanish 
    ) where 

inChinese = "Ni Hao" 
inSpanish = "Hola" 

main = do 
    print inChinese 
    print inSpanish 
+0

仍然無效,同樣的錯誤。 – BufBills

+5

和模塊名稱必須大寫,就像類型 – jberryman

+0

@jberryman的權利,謝謝。但我有另一個問題。請看原文帖子 – BufBills