Why can't Haskell load or find modules?

Viewed 136

I have as Haskell file which uses a lot of imports.

When I try to execute it with the command "ghc -o main main.hs && ./main", I get the below error message:

main.hs:4:8: error:
    Could not load module ‘Prelude’
    It is a member of the hidden package ‘base-4.12.0.0’.
    You can run ‘:set -package base’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v to see a list of the files searched for.
  |
4 | module Main where
  |        ^^^^

main.hs:6:1: error:
    Could not find module ‘Data.Aeson’
    Perhaps you meant
      Data.Version (needs flag -package-key base-4.12.0.0)
    Use -v to see a list of the files searched for.
  |
6 | import Data.Aeson
  | ^^^^^^^^^^^^^^^^^

main.hs:7:1: error:
    Could not load module ‘Data.Text’
    It is a member of the hidden package ‘text-1.2.3.1’.
    You can run ‘:set -package text’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v to see a list of the files searched for.
  |
7 | import Data.Text (Text)
  | ^^^^^^^^^^^^^^^^^^^^^^^

main.hs:10:1: error:
    Could not find module ‘Network.Wreq’
    Use -v to see a list of the files searched for.
   |
10 | import Network.Wreq
   | ^^^^^^^^^^^^^^^^^^^

I have installed all of the necessary modules from the Haskell package manager using cabal.

Why aren't the imports working?

0 Answers
Related