[Haskell-cafe] Hierarchical modules issue

Vo Minh Thu noteed at gmail.com
Mon Jul 19 00:43:21 EDT 2010


2010/7/19 Ivan Miljenovic <ivan.miljenovic at gmail.com>:
> On 19 July 2010 14:31, Jonathan Geddes <geddes.jonathan at gmail.com> wrote:
>> Now when I'm working in a subdirectory, say Foo where the modules are
>> named Foo.Bar, Foo.Baz, Foo.etc., and I try to compile Bar.hs which
>> imports Foo.Baz, the compiler looks for the file Foo/Baz.hs. The
>> problem is that I'm already in the directory Foo and so the compiler
>> fails to find the file for the module Foo.Baz. If I compile the whole
>> project from the root project directory where the main file is, the
>> compiler finds every module just fine.
>
> A similar query was just asked:
> http://www.haskell.org/pipermail/haskell-cafe/2010-July/080523.html
>
>> It seams very strange to me that when the compiler is compiling a
>> module named Foo.Bar and there is an import for Foo.Baz, the compiler
>> doesn't look in the directory where Foo.Bar is located (the current
>> dir)!
>
> Run ghc[i] from the root (source) directory of your project, not
> within the hierarchy (note that haskell-mode for emacs tries to do
> this by finding where the .cabal file is, etc.).

Alternatively, you can fire ghci with the -i option, e.g. ghci -i.. to
look at the directory above (not there is no space between the -i and
the ..). I do this to run tests which are located in a subdirectory.

Otherwise I follow Ivan's advice of running from the root (which makes
it easy to open any other file: sub-module, README, or .cabal).

Cheers,
Thu


More information about the Haskell-Cafe mailing list