0

During the development, I've added a library to package.yaml and the GHCi is already started.

For example, I've added the bytestring library:

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

Because I use it in a file that is called Families.hs and it contains the following code:

{-# LANGUAGE  TypeFamilies, OverloadedStrings #-}

module Families where

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

When I try to load the file, it complains:

: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.

The question is, how to reload the whole project into the GHCi and allow usage of bytestring library.

UPDATE
I also tried with :reload and got

: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.
Will Ness
  • 70,110
  • 9
  • 98
  • 181
softshipper
  • 32,463
  • 51
  • 192
  • 400

1 Answers1

0

I see you are using Spacemacs along with intero. In this case you may restart whole intero process by typing M-x intero-restart RET, or M-RET i r which will reload all stack dependencies.

Another way to do this is to put your cursor on the error import and type C-c C-r to let the intero automatically fix the issue.

radrow
  • 6,419
  • 4
  • 26
  • 53