[Haskell-cafe] Cabal builds file at top level incorrectly

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Wed Dec 10 19:09:42 UTC 2014


Cabal's behaviour is strange to me.  My example cabal file is as follows:

name: break
version: 0.1
cabal-version: >= 1.2
build-type: Simple

library
    hs-source-dirs: src
    build-depends:
        base >= 4 && < 5
    exposed-modules: Break

and I have a module `src/Break.hs` that I want it to compile.  That would
work fine.  But if I have another file at the top-level caled `Break.hs` it
compiles that one instead.  It also seems to want it to be an executable.

What's going on?

Full reproduction below.  You can see it is trying to compile `Break.hs` not
`src/Break.hs`.


% git clone https://github.com/tomjaguarpaw/break.git
Cloning into 'break'...
[...]
% cd break 
% cabal configure && cabal test                      
Resolving dependencies...
Configuring break-0.1...
Re-configuring with test suites enabled. If this fails, please run configure
manually.
Resolving dependencies...
Configuring break-0.1...
Building break-0.1...
Preprocessing library break-0.1...
[1 of 1] Compiling Main             ( Break.hs, dist/build/Main.o )

Break.hs:1:1:
    The function `main' is not defined in module `main:Main'


More information about the Haskell-Cafe mailing list