cabal
cabal copied to clipboard
Support `main-is` inside "common stanzas"
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.
@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 https://github.com/haskell/cabal/issues/2832#issuecomment-236696081
@hvr Thanks for the information! This makes sense. Issue #5531 looks similar.
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.
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
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.
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