Haskell – GHCi cannot find modules of the program

cabalemacshaskell

I'm working on a project and I'm using Cabal for management. I've specified directory of source files, modules, all the stuff. All my files have the same names as their corresponding modules, case is preserved.

I can do:

$ cabal configure
$ cabal build

without problems.

However, imagine I have a module Module in file Module.hs, and file File.hs in the same directory. Now, when I'm trying to load 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 make it find files of my project?

Best Answer

You can launch the REPL via Cabal like so:

# cabal repl

This is the same as running ghci, but will take into account any additional dependencies installed by cabal install your local or sandbox package repository.