我把這個~/Desktop/Shapes.hs
:爲什麼我不能導入此哈斯克爾模塊?
module Shapes
(Shape(Rectangle)
) where
data Shape = Circle | Rectangle deriving (Show)
然後我做到這一點:
cd ~/Desktop
ghci
ghci> :m +Shapes
<no location info>:
Could not find module `Shapes'
It is not a module in the current program, or in any known package.
ghci> import Shapes
<no location info>:
Could not find module `Shapes'
It is not a module in the current program, or in any known package.
爲什麼我得到這個錯誤?
我也試圖與ghc -c Shapes.hs
第一編譯。它仍然不起作用。
我安裝在我的OS X 10.9.2小牛從haskell.org的 「哈斯克爾平臺2013.2.0.0爲Mac OS X,64位」。我也遵循他們的ghc-clang-wrapper
說明。
更新:
有人建議做:l Shapes.hs
第一。問題是,:l Shapes.hs
加載整個形狀文件,這意味着我可以訪問Circle
值構造函數,即使我沒有導出它。見我剛纔的問題:Why can I use this "private" value constructor?我想加載只有模塊。這可能嗎?
我已經更新了我的問題有這個問題。 – stackoverflowuser
@stackoverflowuser首先':加載Shapes.hs',然後':模塊Shapes'。 –