Skip to content

Support main-is inside "common stanzas" #6117

New issue

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

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

Already on GitHub? # to your account

Open
chshersh opened this issue Jun 28, 2019 · 6 comments
Open

Support main-is inside "common stanzas" #6117

chshersh opened this issue Jun 28, 2019 · 6 comments
Labels
Cabal: common stanza Concerning `common` stanzas in `.cabal` files Cabal: file format re: main Concerning the `main-is` field type: enhancement

Comments

@chshersh
Copy link
Member

My use case is that I have a lot of executables placed in different folders. Every executable contains a single Haskell source code file called Main.is. I would like to remove some boilerplate by putting main-is: Main.hs into common stanza (with other options). However, when I do this, I see the following build error message:

No 'main-is' field found for executable my-exe1
No 'main-is' field found for executable my-exe2
No 'main-is' field found for executable my-exe3
No 'main-is' field found for executable my-exe4
No 'main-is' field found for executable my-exe5

It would be really nice if common stanzas could support main-is field as well.

@hvr
Copy link
Member

hvr commented Jun 28, 2019

@chshersh common stanzas are designed to be "typed" and the current one we support is of type "build-info" which is the common denominator of all stanzas where you're allowed to include common stanzas.

What you're asking is basically to implement the common-executable type; see also discussion at #2832 (comment)

@chshersh
Copy link
Member Author

@hvr Thanks for the information! This makes sense. Issue #5531 looks similar.

@andreasabel
Copy link
Member

Me too.
I think it is unintuitive that common only supports some fields. I tried to include main-is and type (for test-suite) but both are rejected.

@andreasabel andreasabel added the Cabal: common stanza Concerning `common` stanzas in `.cabal` files label Jul 22, 2022
@jneira
Copy link
Member

jneira commented Jul 22, 2022

Hmm otoh i agree with hvr point of view (also accepted by the issue author). I think it is cleaner to have a common-executables stanza than add fields to the common one which are only applicable to some stanzas

@chshersh
Copy link
Member Author

I would encourage to not introduce separate common-executables stanza. This introduces another layer of unnecessary complexity. I think nothing stops common stanzas from being typed but still support different stanza types. You just need a proper type for this 😉

I see choosing BuildInfo for common stanzas as an easy and first step to implement this feature. But we can iterate on it and support more and more fields over type.

@jneira
Copy link
Member

jneira commented Jul 22, 2022

I think nothing stops common stanzas from being typed but still support different stanza types. You just need a proper type for this

yeah, that sounds better

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Cabal: common stanza Concerning `common` stanzas in `.cabal` files Cabal: file format re: main Concerning the `main-is` field type: enhancement
Projects
None yet
Development

No branches or pull requests

4 participants