3

I have 2 Haskell modules in emacs: Mod1.hs and Mod2.hs

Mod1.hs:

module Mod1 where
...

In the second module i try to import first module:

import Mod1

But get error:

 Could not find module `Mod1':
      Use -v to see a list of the files searched for.
Failed, modules loaded: none.

In emacs i use standard Haskell-mode. Mod1.hs and Mod2.hs files in the same directory.

How can i fix it?

Thank you.

2 Answers 2

5

You need to set the search-path of the interpreter running in Emacs to include the directory with your files. In the GHCi interpreter do:

Prelude> :cd /home/you/projects/yourproject

Replacing /home/you/projects/yourproject with the path to your .hs files of course. (Do :!pwd in the interpreter to print the current path.) You should then be able to do:

Prelude> :l Mod2

(Or C-c C-l in the Mod2.hs buffer.) See the GHC user guide for details.

Sign up to request clarification or add additional context in comments.

Comments

2

This may help, if you put it in your .emacs:

(setq inferior-haskell-find-project-root nil)

It tells ghci not to move from the current directory.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.