Discussion:
[Haskell-beginners] Cabal modules and directories
Rehno Lindeque
2010-03-03 18:57:13 UTC
Permalink
I'm sorry because this is a very elementary question but despite my attempts
I can't seem to get cabal working for my project structure.

I have two main source directories:
src\haskell
src\semanticdb

Inside src\haskell I have main.hs with the module Main.
Inside src\semanticdb I have semanticdb.hs with module OSIX.SemanticDB

My cabal file contains the following 3 lines:
main-is: main.hs
hs-source-dirs: src/haskell src/semanticdb
other-modules: OSIX.SemanticDB

Then when I build with 'cabal build' I get the following error:
cabal: can't find source for OSIX.SemanticDB in src/haskell,
src/semanticdb, dist/build/autogen

cabal --version gives:
cabal-install version 0.6.4
using version 1.6.0.3 of the Cabal library

I'd prefer to keep my directory structure as is if possible, but it doesn't
seem to be working for me... Is there anything I can do or should I just
restructure the directories?
(NOTE: I'm using leksah as my IDE, so the cabal file is mostly generated
automatically)

Thanks,
-Rehno
Daniel Fischer
2010-03-03 19:19:24 UTC
Permalink
Post by Rehno Lindeque
I'm sorry because this is a very elementary question but despite my
attempts I can't seem to get cabal working for my project structure.
src\haskell
src\semanticdb
Inside src\haskell I have main.hs with the module Main.
Inside src\semanticdb I have semanticdb.hs with module OSIX.SemanticDB
module OSIX.SemanticDB

must be in the file 'SemanticDB.hs' (or .lhs), in the subdirectory OSIX of
the source directory listed in the .cabal file, here src/semanticdb, so

file:

src/semanticdb/OSIX/SemanticDB.hs
Post by Rehno Lindeque
main-is: main.hs
hs-source-dirs: src/haskell src/semanticdb
other-modules: OSIX.SemanticDB
That is in an executable-stanza,

executable whatever
main-is: ...

, right?
Post by Rehno Lindeque
Then when I build with 'cabal build'
Did you `cabal configure` before?
Post by Rehno Lindeque
cabal: can't find source for OSIX.SemanticDB in src/haskell,
src/semanticdb, dist/build/autogen
cabal-install version 0.6.4
using version 1.6.0.3 of the Cabal library
I'd prefer to keep my directory structure as is if possible, but it
doesn't seem to be working for me... Is there anything I can do or
should I just restructure the directories?
(NOTE: I'm using leksah as my IDE, so the cabal file is mostly generated
automatically)
Thanks,
-Rehno
Rehno Lindeque
2010-03-03 19:35:41 UTC
Permalink
Post by Rehno Lindeque
Post by Rehno Lindeque
I'm sorry because this is a very elementary question but despite my
attempts I can't seem to get cabal working for my project structure.
src\haskell
src\semanticdb
Inside src\haskell I have main.hs with the module Main.
Inside src\semanticdb I have semanticdb.hs with module OSIX.SemanticDB
module OSIX.SemanticDB
must be in the file 'SemanticDB.hs' (or .lhs), in the subdirectory OSIX of
the source directory listed in the .cabal file, here src/semanticdb, so
Thanks, moving the file to src/semanticdb/OSIX works. However, I would
prefer it if restructuring my directories weren't necessary. Is it possible?
Rehno Lindeque
2010-03-03 19:54:21 UTC
Permalink
Post by Rehno Lindeque
Post by Rehno Lindeque
I'm sorry because this is a very elementary question but despite my
attempts I can't seem to get cabal working for my project structure.
  src\haskell
  src\semanticdb
Inside src\haskell I have main.hs with the module Main.
Inside src\semanticdb I have semanticdb.hs with module OSIX.SemanticDB
module OSIX.SemanticDB
must be in the file 'SemanticDB.hs' (or .lhs), in the subdirectory OSIX of
the source directory listed in the .cabal file, here src/semanticdb, so
Thanks, moving the file to src/semanticdb/OSIX works. However, I would prefer it if restructuring my directories weren't necessary. Is it possible?
Perhaps I should add that the project isn't haskell-only and already
has some conventions in place such as using lower case for directories
etc. Thus I prefer not to change these. Compilation worked with the
current directory structure using a makefile but I can't duplicate the
feat with cabal. Is there a work-around perhaps?

Also, the 'executable' part and 'cabal configure' is correct, yes :)
Daniel Fischer
2010-03-03 19:59:29 UTC
Permalink
Post by Rehno Lindeque
Thanks, moving the file to src/semanticdb/OSIX works. However, I would
prefer it if restructuring my directories weren't necessary. Is it possible?
No, the hierarchical module names map directly to the directory structure,
module A.B.C must be in the file C.[l]hs in the directory A/B, viewed from
the root of the source tree (the directory you name in hs-source-dirs).
Rehno Lindeque
2010-03-03 20:08:07 UTC
Permalink
Post by Daniel Fischer
Post by Rehno Lindeque
Thanks, moving the file to src/semanticdb/OSIX works. However, I would
prefer it if restructuring my directories weren't necessary. Is it possible?
No, the hierarchical module names map directly to the directory structure,
module A.B.C must be in the file C.[l]hs in the directory A/B, viewed from
the root of the source tree (the directory you name in hs-source-dirs).
Right, thank you. Then perhaps I will try and separate the SemanticDB
into a separate cabal project and try to add it as a dependency.
Thanks for the help.
Daniel Fischer
2010-03-04 17:11:49 UTC
Permalink
Post by Rehno Lindeque
Post by Daniel Fischer
Post by Rehno Lindeque
Thanks, moving the file to src/semanticdb/OSIX works. However, I
would prefer it if restructuring my directories weren't necessary. Is
it possible?
No, the hierarchical module names map directly to the directory
structure, module A.B.C must be in the file C.[l]hs in the directory
A/B, viewed from the root of the source tree (the directory you name
in hs-source-dirs).
Ah, actually I misremembered, according to

http://hackage.haskell.org/trac/haskell-
prime/wiki/DottedHierarchicalModules

you can also have the file with dots in the filename.
Post by Rehno Lindeque
Right, thank you. Then perhaps I will try and separate the SemanticDB
into a separate cabal project and try to add it as a dependency.
Thanks for the help.
Rehno Lindeque
2010-03-04 17:40:19 UTC
Permalink
Post by Daniel Fischer
Post by Daniel Fischer
Post by Rehno Lindeque
Thanks, moving the file to src/semanticdb/OSIX works. However, I
would prefer it if restructuring my directories weren't necessary. Is
it possible?
No, the hierarchical module names map directly to the directory
structure, module A.B.C must be in the file C.[l]hs in the directory
A/B, viewed from the root of the source tree (the directory you name
in hs-source-dirs).
Ah, actually I misremembered, according to
http://hackage.haskell.org/trac/haskell-
prime/wiki/DottedHierarchicalModules
you can also have the file with dots in the filename.
Mmm, I tried it out but it doesn't seem to work for me. I found this
extensions support matrix on
http://hackage.haskell.org/trac/haskell-prime/wiki/HaskellExtensions
that indicates that GHC doesn't support DottedHierarchicalModules. It
appears to be a JHC extension...

Loading...