相关疑难解决方法(0)

在ghci中指定"加载"操作的搜索路径

加载源文件时,它指出使用-i选项指定用于查找源文件的搜索路径:

ghci -idir1:...:dirn
Run Code Online (Sandbox Code Playgroud)

这是否意味着当一个人执行时:

:load test.hs
Run Code Online (Sandbox Code Playgroud)

然后ghci在上面的目录中查找test.hs?我在问题指定源目录到GHC时看到了响应, 但我仍然不清楚这一点.

例如,在Windows XP中,我将test.hs放入:

C:\Documents and Settings\winuser\My Documents
Run Code Online (Sandbox Code Playgroud)

然后跑:

ghci -iC:\Documents and Settings\winuser\My Documents
Run Code Online (Sandbox Code Playgroud)

但是,在做的时候:load test.hs,ghci抱怨无法找到该文件.

[编辑1]

我想避免使用,:cd因为它卸载了所有已加载的模块,这阻止我从多个位置加载文件

[编辑2:对jozefg的回应]

--C:\A\A.hs
module A where
myaddA::Int->Int->Int
myaddA x y = x+y

--C:\B\B.hs
module B where
myaddB::Int->Int->Int
myaddB x y = x+y
Run Code Online (Sandbox Code Playgroud)

然后我可以做以下事情:

Prelude> :cd C:\A
Prelude> :load A
[1 of 1] Compiling A                ( A.hs, interpreted )
Ok, modules loaded: A.
*A> myaddA 2 3
5
*A> :cd …
Run Code Online (Sandbox Code Playgroud)

haskell ghci

6
推荐指数
1
解决办法
4367
查看次数

标签 统计

ghci ×1

haskell ×1