Specifying the search path for “load” operations in ghci

喜你入骨 提交于 2019-12-03 15:04:42

The load path is how GHCi searches for modules. So if you named your module Test.hs and added

 module Test where

Than you can do

 > :load Test

otherwise you can use

 > :cd SomeDirectory
 > :load test.hs

Response to edit:

(Warning, I run eshell so the commands/paths look different)

~         $ mkdir temp
~         $ mkdir temp/temp temp/temp2
temp      $ find-file temp/A.hs
-- In A.hs
module A where
addA = (+)
--
temp      $ find-file temp2/B.hs
-- In B.hs
module B where
addB = (+)
--
temp      $ cd temp
temp/temp $ ghci -i../temp2
> :load A B
> import B

And now I have access to both A and B.

In the context of running ghci with stack.

Step 1:

 stack ghci --ghci-options -i"C:\Documents and Settings\winuser\My Documents"

Step 2: (inside ghci)

:show paths

module import search paths: c:\Documents

It seems ghci doesn't like "space" in the path

Step 3: (still inside ghci)

:set -iC:\Users\zheh\Desktop\code\Craft3e-0.1.0.10

Step 4: (still inside ghci)

:show paths

So avoid "space" inside path. Search paths can be set with command line options at the beginning or inside ghci, and be checked with :show paths

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!