GHCi cannot find my program modules

I am working on a project and I use Cabal for management. I set the directory of source files, modules, all things. All my files have the same names as their corresponding modules, the register is saved.

I can do:

$ cabal configure $ cabal build 

no problem.

However, imagine that I have a Module module in the Module.hs file and a File.hs file in the same directory. Now, when I try to download File.hs from Emacs for testing, I get the following:

 ____Could not find module 'Module' It is a member of the hidden package 'ghc-7.8.3'. Use -v to see a list of the files searched for. Failed, modules loaded: none. 

Full contents of File.hs :

 module File where import Module 

How to find my project files?

+5
source share
2 answers

You need to tell GHCi where to find the source files. For example, if your project directory is ./foo and you have the source files in ./foo/src , you need to say (from your project directory):

 :set -isrc 

at the command prompt in GHCi. You will then gain access to the private members in the sourc file downloaded using Cc Cl .

You also need to make sure that you do not have cabal install your package, otherwise the package will be downloaded, not the project source files.

+4
source

You can run REPL through Cabal as follows:

# cabal repl

This is the same as starting ghci , but any additional dependencies installed by installing cabal in local or isolated package storage will be taken into account.

+5
source

Source: https://habr.com/ru/post/1204899/


All Articles