命令(在GHCi中)
:load abc-------------------------------------------------- --------------------------------
[对下文的回复]
嗨Rotskoff,谢谢我尝试了你的建议,但是我无法完成它的工作,所以我想我一定误解了一些东西。
我创建了3个文件test.hs,test1.hs和test2.hs,如下所示:
- >
--test.hs import NecessaryModule-------------------------------------------------- -------------------------------
谢谢。 这是我为了让它工作而做的(遵循Rotskoff的建议):
- >
--test.hs import NecessaryModule1 import NecessaryModule2----------------------------------------------------------------------------------
[RESPONSE TO POST BELOW]
Hi Rotskoff, thanks I tried your suggestion but I could not get it to work, so I think I must have misunderstood something.
I created 3 files test.hs, test1.hs, and test2.hs as follows :
->
--test.hs import NecessaryModule---------------------------------------------------------------------------------
Thanks. This is what I did to get it to work (following Rotskoff's suggestion) :
->
--test.hs import NecessaryModule1 import NecessaryModule2->
--NecessaryModule1.hs addNumber1 :: Int -> Int -> Int addNumber1 a b = a + b->
--NecessaryModule2.hs addNumber2 :: Int -> Int -> Int addNumber2 a b = a + b最满意答案
推测你的意思是Haskell源文件,因为你不能在GHCi中使用:load命令来做其他事情。
在加载的源文件的顶部,包含以下行:
import NecessaryModule
对于每个源文件,确保命名模块,例如,
module NecessaryModule where
应该出现。 GHCi会自动链接所有文件。
如果您要导入数据,请查看文档中的System.Directory 。
Presumably you mean Haskell source files, because you can't use the :load command in GHCi for anything else.
At the top of the source file that you load, include the line:
import NecessaryModule
For each of the source files, make sure to name the modules, e.g.,
module NecessaryModule where
should appear. GHCi will automatically link all the files.
If you're trying to import data, take a look at System.Directory in the documentation.
更多推荐
发布评论