5

I am trying to write a package in Haskell. This package contains a library and an executable. I am specifying this in the Cabal file. There are three basic components of the library:

1) There are the exposed modules of the library

2) There are internal build-dependencies that should not be exported as part of the library

3) There are external build-dependencies.

There is a bit of overlap in the Cabal file. For the library I write:

exposed-modules: The List of Exposed Modules

other-modules: The List of other modules

build-depends: The List of build dependencies

Then for the executable other-modules: The list of exposed modules and other modules are needed in the executable build-depends: The list of build dependencies

What would be nice is if Cabal lets me have a variable.

V1 = List exposed modules

V2 = List other modules

V3 = List build dependencies

Then in the executable, for example, I could do

other-modules: V1,V2

build-depends: V3

Alternatively, I would take a recommendation for a better way to use the Cabal system!

4

1 回答 1

3

不,这还不可能。我认为我们在某个地方的问题跟踪器上有类似这样的功能请求。但是请注意,您的可执行文件可以依赖于同一.cabal文件中定义的库,因此您不必共享exposed-modulesand other-modules

Name: some-package
Version: 0.1
[...]

Library
    build-depends: some-dependency >= 1.0, ...        
    exposed-modules: A, B, C
    other-modules: C, D, E
    [...]

Executable some-exe
    main-is: SomeExe.hs
    build-depends: some-package == 0.1

有关真实世界的示例,请参见此处

于 2013-09-09T23:04:07.003 回答