[Haskell-beginners] Cabal dependencies are per target or global?

Dimitri DeFigueiredo defigueiredo at ucdavis.edu
Fri Jul 17 19:59:16 UTC 2015


Hello,

I'm trying to figure out how cabal understands dependencies.

It seems all "build-depends:" sections have to build satisfied for any one
target to be built. Is that correct or is there a problem with my setup?

I assumed those "build-depends:" sections were "per target",
but apparently that not exactly the case.

I have a small .cabal file that builds the second target "myPersonalMain"
if and only if I comment out the build-dependencies for the first target 
(i.e. myAgent)

here's my test file agent.cabal:
------------------------------------------------
name:                agent
version:             0.1.0.0
synopsis:            Just testing
author:              Dimitri DeFigueiredo
maintainer:          defigueireo at ucdavis.edu
build-type:          Simple
cabal-version:       >=1.20

----------------------------------------------
executable myAgent
   main-is:              Main.hs
   hs-source-dirs:       ./src

   build-depends:      base >=4.6 && <4.7
                     , unordered-containers >= 0.2.3.0
                     , unix >= 2.6.0.1
                     , process >= 1.1.0.2
                     , stm >= 2.4.2

   default-language:    Haskell2010

----------------------------------------------
executable myPersonalMain
     main-is:            Mpm.hs
     hs-source-dirs:     ./src
     build-depends:
                   base              >=4.6

     default-language:   Haskell2010
----------------------------------------------

if I try to build the second target I get:

cabal build MyPersonalMain
./agent.cabal has been changed. Re-configuring with most recently used
options. If this fails, please run configure manually.
Resolving dependencies...
Configuring agent-0.1.0.0...
cabal: At least the following dependencies are missing:
process >=1.1.0.2,
stm >=2.4.2,
unix >=2.6.0.1,
unordered-containers >=0.2.3.0

could someone shed some light into this behavior?

Thanks,

Dimitri




More information about the Beginners mailing list