[Haskell-cafe] Hierarchical modules issue
geddes.jonathan at gmail.com
Mon Jul 19 00:31:20 EDT 2010
When I'm developing Haskell code I like to frequently compile the file
I'm currently working on so that the compiler will tell me if and
where I've made mistakes. In my text editor I have a key mapped to do
just that. I have another key mapped to fire up ghci with the current
file so I can play around with the functions I've defined. I find this
workflow to be very productive.
I recently reorganized a project to take advantage of hierarchical
modules and it broke my workflow.
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.
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
My temporary soluation has been to create symlinks to help the
compiler find what it's looking for. For example in the Foo directory
I have a symlink to that same Foo directory so that when compiling
Bar.hs, the compiler finds Foo/Baz.hs when it looks for it. However,
this seems like a dirty hack and it's not portable besides.
Is this a known issue? Is there a better solution than mine? Is there
something I'm missing?
More information about the Haskell-Cafe