Visitar URL original
Improve `build-type` defaulting by hvr · Pull Request #4958 · haskell/cabal · GitHub
Skip to content

Improve build-type defaulting - #4958

Merged
hvr merged 5 commits into
haskell:masterfrom
hvr:pr/btype-defaulting
Dec 18, 2017
Merged

hvr merged 5 commits into
haskell:masterfrom
hvr:pr/btype-defaulting

Conversation

@hvr

@hvr hvr commented Dec 17, 2017 •

Copy link
Copy Markdown
Member

A personal DRY-pet-peeve of mine when writing .cabal files from scratch is forgetting about declaring the build-type, which historically will then be inferred to be Custom which is almost always not what is desired. Instead, a better default is Simple as that represents the most basic and recommended build-type. Morever, starting with cabal-version:1.24, we have a redundant signal in the .cabal file to statically imply a custom build-type, namely the custom-setup stanza.

To this end, this PR finally removes this papercut by improving the defaulting to use the following simple rules:

  • When cabal-version is set to 2.1 or higher, the default is Simple unless a custom-setup stanza exists, in which case the inferred default is Custom.
  • For cabal-versions below 2.1, the default is Custom unconditionally (legacy defaulting).

This allows us to bring down the minimal (modern) trivial cabal package definition down to a single file with 4 lines:

cabal-version: 2.1
name: mu
version: 0
library

NB: We don't need any Setup.hs file, as cabal new-build doesn't need any, and cabal sdist will magically generate one on the fly and include it in the source distribution.


Please include the following checklist in your PR:

  • Patches conform to the coding conventions.
  • Any changes that could be relevant to users have been recorded in the changelog.
  • The documentation has been updated, if necessary.
  • Test-suite has been extended/updated

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants