In Haskell, modules name and file name containing the module have to be the same. The problem is is not only the file name but the includes the all path, so you have (AFAIK) to create a directory structure matching the module hierarchy, which is a bit annoying.
For example, let's say that I'm writing a datatype D in a module M which I think should be in Database
.
The module name should be Database.M.T
. As my main directory is already called M (the name of the package) I end up with the following directory structure :
M:
|
+-- Database:
|
+-- M:
|
+ A.hs
Is that possible to just do :
M:
|
+ A.hs
And export M
as Database.M
?
This isn't possible at present, short of using symlinks or similar to point Database.M
to M
which would have various problems with portability and version control.
Simon Marlow proposed a new option for GHC to add support for aliases a few months ago: http://www.haskell.org/pipermail/glasgow-haskell-users/2014-April/024920.html
His idea was that you could run ghc
with a new variant of the -i
option:
ghc -iDatabase.M=M
and then anything in the M
folder would be treated as being part of Database.M
as you want.
You'd also be able to put the new option in the hs-source-dirs
field in .cabal
files.
However there were various objections to the proposal so he's withdrawn it for now. The main problems were that it adds complexity and several other tools (e.g. cabal
) would also have to be changed to support it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With