Skip to content

implicit common stanzas (a.k.a. common blocks) #5530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
daig opened this issue Aug 18, 2018 · 5 comments
Open

implicit common stanzas (a.k.a. common blocks) #5530

daig opened this issue Aug 18, 2018 · 5 comments
Labels
Cabal: common stanza Concerning `common` stanzas in `.cabal` files type: enhancement

Comments

@daig
Copy link

daig commented Aug 18, 2018

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.

@hvr
Copy link
Member

hvr commented Aug 18, 2018

Have you seen the original design discussion at #2832 ? The idea of implicit common blocks was anticipated there already

@jneira
Copy link
Member

jneira commented Jun 12, 2021

afaik cabal already supports common stanzas, which can include common dependencies, so this could be closed?

@jneira
Copy link
Member

jneira commented Jun 12, 2021

#2832 is closed so I think we can close this
@daig thanks for your original feature request

@fgaz
Copy link
Member

fgaz commented Jun 13, 2021

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?

@jneira jneira reopened this Jun 13, 2021
@jneira
Copy link
Member

jneira commented Jun 13, 2021

Oh sorry, i missed the implicit part.

@andreasabel andreasabel added the Cabal: common stanza Concerning `common` stanzas in `.cabal` files label Jul 22, 2022
@ulysses4ever ulysses4ever changed the title common blocks or implicit common stanzas implicit common stanzas (a.k.a. common blocks) Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cabal: common stanza Concerning `common` stanzas in `.cabal` files type: enhancement
Projects
None yet
Development

No branches or pull requests

5 participants