添加依赖项后如何重新加载项目?

时间:2019-02-22 10:41:18

标签: haskell emacs spacemacs intero

在开发过程中,我已经向package.yaml添加了一个库,并且GHCi已经启动。

例如,我添加了bytestring库:

executables:
  playground-exe:
    main:                Main.hs
    source-dirs:         app
    ghc-options:
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
    dependencies:
    - playground
    - text
    - bytestring

因为我在名为Families.hs的文件中使用了它,它包含以下代码:

{-# LANGUAGE  TypeFamilies, OverloadedStrings #-}

module Families where

import Data.Word (Word8)
import qualified Data.ByteString as BS 

当我尝试加载文件时,它抱怨:

:l ./src/Families.hs
[1 of 1] Compiling Families         ( src/Families.hs, interpreted )

src/Families.hs:6:1: error:
    Could not load module ‘Data.ByteString’
    It is a member of the hidden package ‘bytestring-0.10.8.2’.
    You can run ‘:set -package bytestring’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v to see a list of the files searched for.
  |
6 | import qualified Data.ByteString as BS
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Failed, no modules loaded.

问题是,如何将整个项目重新加载到GHCi中,并允许使用bytestring库。

更新
我也尝试过:reload并得到

:reload
[1 of 1] Compiling Families         ( src/Families.hs, interpreted )

src/Families.hs:6:1: error:
    Could not load module ‘Data.ByteString’
    It is a member of the hidden package ‘bytestring-0.10.8.2’.
    You can run ‘:set -package bytestring’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v to see a list of the files searched for.
  |
6 | import qualified Data.ByteString as BS
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Failed, no modules loaded.

1 个答案:

答案 0 :(得分:0)

我看到您正在将Spacemacs与intero一起使用。在这种情况下,您可以通过键入M-x intero-restart RETM-RET i r重新启动整个内部操作过程,这将重新加载所有堆栈依赖项。

另一种方法是将光标放在错误导入上,然后键入C-c C-r,让intero自动解决该问题。