0

在开发过程中,我添加了一个库,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.
4

1 回答 1

0

我看到您正在使用 Spacemacs 和intero. 在这种情况下,您可以通过键入重新启动整个 intero 进程M-x intero-restart RET,或者M-RET i r这将重新加载所有堆栈依赖项。

另一种方法是将光标放在错误导入上并键入C-c C-r以让intero自动修复问题。

于 2019-02-22T15:28:13.987 回答