Skip to content

feat(Cabal, cabal-install): Display -O and -g as numeric levels instead of booleans - #11937

Open
zlonast wants to merge 7 commits into
haskell:masterfrom
zlonast:zlonast/numeric-render
Open

feat(Cabal, cabal-install): Display -O and -g as numeric levels instead of booleans#11937
zlonast wants to merge 7 commits into
haskell:masterfrom
zlonast:zlonast/numeric-render

Conversation

@zlonast

@zlonast zlonast commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

This PR improves the handling of the debug-info and optimization field to ensure consistency between its configuration and CLI representations.

Changes

  • Config default: Updated the serialization logic to represent the default NoDebugInfo value as 0 instead of False in ~/.config/cabal/config.
  • Internal consistency: Aligned the default DebugInfoLevel between pkgHashDebugInfo and the Parsec instance. This resolves potential inconsistencies when processing manually generated configuration files.
  • Parsing fix: Fixed a bug where boolean flags were not being correctly parsed for the debug-info field. The parser now properly handles both boolean and integer inputs.
    -- TODO: [code cleanup] The following is a hack. The "optimization" and
    -- "debug-info" fields are OptArg, and viewAsFieldDescr fails on that.
    -- Instead of a hand-written parser and printer, we should handle this case
    -- properly in the library.

    -- TODO: The following is a temporary fix. The "optimization"
    -- and "debug-info" fields are OptArg, and viewAsFieldDescr
    -- fails on that. Instead of a hand-written hackaged parser
    -- and printer, we should handle this case properly in the
    -- library.

Template Α: This PR modifies behaviour or interface

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.
  • Tests have been added. (Ask for help if you don’t know how to write them! Ask for an exemption if tests are too complex for too little coverage!)

@zlonast
zlonast force-pushed the zlonast/numeric-render branch from f9af0be to 0eeaea7 Compare June 7, 2026 17:57
@zlonast zlonast changed the title Numeric render feat(Cabal, cabal-install): Display -O and -g as numeric levels instead of booleans Jun 9, 2026
@zlonast
zlonast force-pushed the zlonast/numeric-render branch from 0eeaea7 to c08916a Compare June 9, 2026 13:08
@zlonast zlonast added attention: needs-review re: code formatting Automated code formatting with Fourmolu or similar type: refactor labels Jun 9, 2026
@zlonast
zlonast force-pushed the zlonast/numeric-render branch 3 times, most recently from 7b61363 to f7abbb6 Compare June 10, 2026 11:04
@zlonast zlonast linked an issue Jun 10, 2026 that may be closed by this pull request
@Mikolaj

Mikolaj commented Jun 11, 2026

Copy link
Copy Markdown
Member

@ffaf1 notices this seems to change the behaviour of cabal (namely, it's output). If so, a different PR template should be used, which asks for a different set of tasks.

Would it be possible to add a test that prints the -O and -g things? Preferably in an early commit, so that it illustrates the modification, showing how it requires a change in the test result.

@zlonast zlonast added the re: config-file Concerning the cabal configuration file and the `--config-file` option label Jun 19, 2026
@zlonast
zlonast force-pushed the zlonast/numeric-render branch 3 times, most recently from 011259e to 5d8b49f Compare June 19, 2026 19:57
@zlonast
zlonast force-pushed the zlonast/numeric-render branch 3 times, most recently from 83a898c to 14c4a11 Compare June 29, 2026 12:09
@Bodigrim

Copy link
Copy Markdown
Collaborator

It seems it needs a rebase now.

@zlonast
zlonast force-pushed the zlonast/numeric-render branch from 14c4a11 to 7552c00 Compare July 12, 2026 10:32
@zlonast

zlonast commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator Author

@Bodigrim yes, I updated it

@Mikolaj add test for prints the -O and -g things

@Mikolaj Mikolaj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't pretend to have read the whole newest diff, but it seems solid overall. Thank you.

Comment thread changelog.d/11937.md
Comment thread Cabal/src/Distribution/Types/DebugInfoLevel.hs Outdated
Comment thread cabal-install/src/Distribution/Client/ProjectPlanning.hs Outdated
@zlonast zlonast linked an issue Jul 28, 2026 that may be closed by this pull request
@zlonast
zlonast force-pushed the zlonast/numeric-render branch from 7552c00 to 538ea9e Compare July 28, 2026 13:44
@zlonast zlonast linked an issue Jul 28, 2026 that may be closed by this pull request
@zlonast
zlonast force-pushed the zlonast/numeric-render branch from 538ea9e to 9ac9012 Compare July 28, 2026 14:22
Comment thread changelog.d/11937.md
@zlonast
zlonast force-pushed the zlonast/numeric-render branch 2 times, most recently from e1f64e1 to faa6838 Compare July 28, 2026 14:54
@zlonast
zlonast requested a review from philderbeast July 29, 2026 03:27
Comment thread changelog.d/11937.md Outdated
@zlonast
zlonast force-pushed the zlonast/numeric-render branch from 7bdbf39 to b2e9812 Compare July 30, 2026 04:44
@zlonast
zlonast requested a review from philderbeast July 30, 2026 14:44
Comment thread Cabal/src/Distribution/Simple/Flag.hs Outdated
Comment thread Cabal/src/Distribution/Types/DebugInfoLevel.hs Outdated
Comment thread Cabal/src/Distribution/Types/OptimisationLevel.hs Outdated
Comment thread changelog.d/11937.md
@zlonast zlonast added the re: API Concerning the Cabal API design label Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

attention: needs-review re: API Concerning the Cabal API design re: code formatting Automated code formatting with Fourmolu or similar re: config-file Concerning the cabal configuration file and the `--config-file` option type: refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: Improve rendering of -O and -g flags as numeric levels

4 participants