2

I've got the following question:

I've got two Haskell libraries that depend on each other, and both libraries are managed by cabal. The corresponding cabal files look like this:

Library 1:

name:           Lib1
version:        0.1
cabal-version:  >=1.2
build-type:     Simple
author:         Matthias

library
  hs-source-dirs:  src
  build-depends:   
               base >= 4,
               Lib2
  ghc-options:     -Wall
  exposed-modules:   <...>

Library 2:

name:           Lib2
version:        0.1
cabal-version:  >=1.2
build-type:     Simple
author:         Matthias

library
  hs-source-dirs:  src
  build-depends:   
               base >= 4,
               Lib1
  ghc-options:     -Wall
  exposed-modules: <...>

Installing one of the libraries (here library 2) with cabal install works:

Resolving dependencies...
In order, the following will be installed:
Lib2-0.1 (reinstall)
Warning: Note that reinstalls are always dangerous. Continuing anyway...
Configuring Lib2-0.1...
Building Lib2-0.1...
Preprocessing library Lib2-0.1...
Registering Lib2-0.1...
Installing library in
C:\Users\Matthias\AppData\Roaming\cabal\Lib2-0.1\ghc-7.4.2
Registering Lib2-0.1...

But trying to install the other library (here library 1) with cabal install results in a dependency error:

Resolving dependencies...
cabal.exe: Could not resolve dependencies:
trying: Lib1-0.1 (user goal)
next goal: Lib2 (dependency of Lib1-0.1)
rejecting: Lib2-0.1/installed-aa4... (package is broken)

Is there any way to handle two such libraries that depend on each other so that I don't get dependency errors or is cabal simply not able to handle such a case properly?

4

1 回答 1

6

正如其他人所说,循环依赖永远不会在 Cabal 中起作用。编译具有循环依赖关系的模块已经够难了,但是是一个无望的原因。

有时可能会非常困难,但唯一真正的解决方案是找到一种方法来以某种方式打破循环依赖。

于 2013-05-09T19:51:39.733 回答