2011-09-12 21 views
3

我有一個問題,我的項目結構:找不到Haskell模塊。我的項目文件結構有什麼問題?

pic-analysis-0.1/AlgTop/Data.hs 
         Functions.hs 
       PNGModify.hs 
       Main.hs 

Data.hs

module AlgTop.Data (…) where 

Functions.hs

module AlgTop.Functions (…) where 
import AlgTop.Data 

AlgTop.Functions模塊沒有找到AlgTop.Data

我在Hackage上比較了我的項目結構方法和ansi-terminal(參見下文),但我無法發現任何區別。我究竟做錯了什麼?

ansi-terminal-xxx/System/Console/ANSI/Common.hs 
            /Unix.hs 
            /… 

Common.hs

module System.Console.ANSI.Common where 

Unix.hs

module System.Console.ANSI.Unix (…) where 
import System.Console.ANSI.Common 

錯誤消息:

[...] 
*** Chasing dependencies: 
Chasing modules from: *Functions.hs 

Functions.hs:9:8: 
    Could not find module `AlgTop.Data': 
     locations searched: 
     AlgTop/Data.hs 
     AlgTop/Data.lhs 
[...] 
+0

如何導入'AlgTop.Functions'? – 2011-09-12 11:09:42

+1

你正在用ghci加載模塊,還是試圖用cabal編譯這個項目?發佈實際的錯誤消息可能會有用。 –

+0

'AlgTop.Functions'是另一個輔助模塊 - 提供邊界操作符和其他功能 - 我的'主要'將被編程。 – epsilonhalbe

回答

4

如果您使用的是ghci,可能是您需要:set -i/.../pic-analysis-0.1。也就是說,包含模塊層次結構的根目錄。

+0

啊 - 我有時非常愚蠢 - 我在vim中使用runhaskell和語法檢查器,因爲這個 – epsilonhalbe

3

無需設置任何東西。只需在啓動GHCi之前先進入根目錄:

ghci AlgTop/Functions.hs 
+0

的根目錄..其中的組件... – nicolas