cabal
cabal copied to clipboard
common blocks or implicit common stanzas
It would be nice to be able to avoid writing the same imports everywhere - this becomes relevant as backpack encourages many internal libraries with similar cabal properties.
The most general way I can imagine is common import blocks that would look something like
import: my-common
library lib-a
...
library lib-b
...
test-suite test-a
...
where each piece within the indented scope implicitly imports my-common
.
another possibility with even less boilerplate at the cost of being less general is to have toplevel implicit imports like
library-common
build-depends: base
...
so that all libraries import it. There'd also be similar constructs for executable, test-suite, benchmark, foreign-library, etc.
Have you seen the original design discussion at #2832 ? The idea of implicit common blocks was anticipated there already
afaik cabal already supports common stanzas, which can include common dependencies, so this could be closed?
#2832 is closed so I think we can close this @daig thanks for your original feature request
afaik cabal already supports common stanzas, which can include common dependencies, so this could be closed?
this issue is different, it's about a common stanzas enhancement that would reduce import bolerplate
and it looks like the proposed extension in #2832:
- reserve a few special common stanza ids all, library, test-suites, and benchmark to declare common stanzas that are implicitly included by the respective named real stanza. In the example above we could have used common all instead of common cdef1 and all include cdef1 simply removed.
wasn't implemented, nor was the proposed unnamed stanza.
I'm not sure why is that. @phadej @hvr was there a reason for it?
Oh sorry, i missed the implicit part.