Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cabal doesn't find Source.hs

Tags:

haskell

cabal

My project structure is as follows:

~/.../project_name
project_name.cabal
Setup.hs
src/
    Main.hs
    Data/
        ...
test/
    MainTestSuite
    ...

I have (amongst others) the following lines in my project.cabal:

build-type:          Simple
...
executable project_name
main-is: Main.hs
...
hs-source-dirs: src

When I cabal configure (works fine) and then cabal build I get the error message:

cabal: can't find source for Setup in src, dist/build/autogen

It works when I put Source.hs in src but this seems messy to me and I haven't seen this in other projects, where Source.hs is always in the project root. How do I get cabal to find Source.hs?


As an aside: What's the purpose of Source.hs anyways?

like image 391
jules Avatar asked Mar 26 '15 10:03

jules


2 Answers

hs-source-dirs: ., src comes to mind as a fast fix.

That's what my projects use, and I generate my cabal files automatically (so I suppose that's the default).

like image 140
Bartek Banachewicz Avatar answered Sep 24 '22 14:09

Bartek Banachewicz


The problem was caused by accidently adding the Source file as a dependency in other-modules in the cabal-file of the project ... that caused all the trouble.

like image 26
jules Avatar answered Sep 22 '22 14:09

jules