[Haskell-cafe] Could we make Haskell Modules "location independent"?

Dimitri DeFigueiredo defigueiredo at ucdavis.edu
Thu Oct 1 19:04:53 UTC 2015


Haskell is a fantastic language for refactoring, but I find the module 
system gets in the way when I need to reorganize my files or am trying 
to use git submodules.

My problem is that each module needs to "know where it is" relative to 
the global source paths in the cabal file.

For example, if you have an import statement like
```
module Main where

import SomeDirectory.SomeModule
```

the file SomeModule.hs must "know" that it is in a subdirectory as it is 
called because its name must have the "SomeDirectory" path as a prefix:

module SomeDirectory.SomeModule where ...

this would not work

module SomeModule where ...

To avoid having to add the SomeDirectory prefix, I end up putting *all* 
directories in the .cabal file.

Question: Why does GHC require an exact match between the modulename and 
the complete path? Is there a way to relax this?

Thanks,

Dimitri



More information about the Haskell-Cafe mailing list