我把这个~/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'。 –